diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2018-05-24 07:21:12 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2018-05-24 12:22:38 +0200 |
commit | 56d1e82d77c5e7269e91dc2b1dbc63c0a15bb6db (patch) | |
tree | ec2e5f295152e78110419bde6211f1145e9f7562 /scripts | |
parent | b28e0798c0be2bdebd7f3d8f4dd1020866e759a9 (diff) | |
download | barebox-56d1e82d77c5e7269e91dc2b1dbc63c0a15bb6db.tar.gz barebox-56d1e82d77c5e7269e91dc2b1dbc63c0a15bb6db.tar.xz |
imx-usb-loader: Fix verify for non word aligned lengths
Verifying the uploaded image fails when the length is not word aligned.
This is because read_memory reads full words, so the input length must
be word aligned. Align the length up to 4 bytes so that we do not pass
unaligned lengths to read_memory.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/imx/imx-usb-loader.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/scripts/imx/imx-usb-loader.c b/scripts/imx/imx-usb-loader.c index cbb17cbab9..7e0a110ab4 100644 --- a/scripts/imx/imx-usb-loader.c +++ b/scripts/imx/imx-usb-loader.c @@ -1164,12 +1164,13 @@ static int verify_memory(const void *buf, unsigned len, unsigned addr) int ret, mismatch = 0; void *readbuf; unsigned offset = 0, now; + unsigned alen = ALIGN(len, 4); - readbuf = malloc(len); + readbuf = malloc(alen); if (!readbuf) return -ENOMEM; - ret = read_memory(addr, readbuf, len); + ret = read_memory(addr, readbuf, alen); if (ret < 0) goto err; |