fb_mmc.c: Correct blk_dread() return value checks
PATCH 1/1 fb_mmc.c: Correct blk_dread() return value checks
The function blk_dread will return -ENOSYS on failure or on success the number of blocks read, which must be the number asked to read (otherwise it failed somewhere). Correct this check.
Cc Lukasz Majewski <[email protected]>
Signed-off-by Tom Rini <[email protected]>
--- common/fb_mmc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
common/fb_mmc.c +2 -2
@@ -132,7 +132,7 @@ static lbaint_t fb_mmc_get_boot_header(struct blk_desc *dev_desc,/* Read the boot image header */ res =blk_dread (dev_desc, info->start, hdr_sectors, (void *)hdr); -if (res ==0 ) { +if (res != hdr_sectors) {error ("cannot read header from boot partition" );fastboot_fail ("cannot read header from boot partition" );return 0 ;
@@ -215,7 +215,7 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc, ramdisk_buffer = (u8 *)hdr + (hdr_sectors * info.blksz); res =blk_dread (dev_desc, ramdisk_sector_start, ramdisk_sectors, ramdisk_buffer); -if (res ==0 ) { +if (res != ramdisk_sectors) {error ("cannot read ramdisk from boot partition" );fastboot_fail ("cannot read ramdisk from boot partition" );return -1 ;
Signature · 1 line
1.9.1
Łukasz Majewski
AppliedPATCH 1/1 fb_mmc.c: Correct blk_dread() return value checks
Quoted 25 lines · Tom Rini
The function
blk_dreadwill return-ENOSYSon failure or on success the number of blocks read, which must be the number asked to read (otherwise it failed somewhere). Correct this check.Cc Lukasz Majewski <[email protected]>Signed-off-by Tom Rini <[email protected]>--- common/fb_mmc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)common/fb_mmc.c +1
-1@@ -132,7 +132,7 @@ static lbaint_t fb_mmc_get_boot_header(struct blk_desc *dev_desc,/* Read the boot image header */ res =blk_dread (dev_desc, info->start, hdr_sectors, (void *)hdr); -if (res ==0 ) { +if (res != hdr_sectors) {error ("cannot read header from boot partition" );fastboot_fail ("cannot read header from boot partition" );return 0 ;
common/fb_mmc.c static int fb_mmc_update_zimage(struct blk_desc *dev_desc, · line 221
Quoted 8 lines
common/fb_mmc.c +1
-1@@ -215,7 +215,7 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc, ramdisk_buffer = (u8 *)hdr + (hdr_sectors * info.blksz); res =blk_dread (dev_desc, ramdisk_sector_start, ramdisk_sectors, ramdisk_buffer); -if (res ==0 ) { +if (res != ramdisk_sectors) {error ("cannot read ramdisk from boot partition" );fastboot_fail ("cannot read ramdisk from boot partition" );return -1 ;
Reviewed-by �ukasz Majewski <[email protected]>
I've applied this patch to -dfu tree.
Signature · 9 lines
Best regards, Lukasz Majewski -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de