common: android: skip blk read and memcpy if image size is 0

blk_read() may return error code if image size is 0, it depends
on block layer implementation.

Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I29bab10835e9029780a957e871a600a6fbdf6068
This commit is contained in:
Joseph Chen 2019-12-20 08:32:59 +08:00
parent 7edaca2270
commit b6b05c7154
1 changed files with 4 additions and 0 deletions

View File

@ -374,6 +374,9 @@ static int image_read(img_t img, struct andr_img_hdr *hdr,
return -ENOMEM;
}
if (!blksz || !datasz)
goto crypto_calc;
/* load */
if (ram_base) {
memcpy(ramdst, (char *)((ulong)ram_base + offset), datasz);
@ -386,6 +389,7 @@ static int image_read(img_t img, struct andr_img_hdr *hdr,
}
}
crypto_calc:
/* sha1 */
#ifdef CONFIG_DM_CRYPTO
if (crypto) {