[U-Boot] There appears to be the potential for an undetected error in fs/ext2/dev.c ext2fs_devread()

Wolfgang Denk wd at denx.de
Mon Jan 18 00:33:55 CET 2010


Dear Quentin Armitage,

In message <1262482223.2820.161.camel at samson.armitage.org.uk> you wrote:
> In fs/ext2/dev.c in function ext2fs_devread(), if after reading the
> first part, there is less than a whole block left to be read (block_len
> == 0), then the return value from ext2fs_block_dev_desc->block_read is
> not tested, and success (1) is always returned to the calling function.

Do you have a test case (for example, a file system image) that can be
used to test this error (i. e. that shows the error with the current
code, and that works with your patch)?

What exactly are the symptoms of the error?

> This particular block of code appears superfluous, since there is
> already code to read the final part, and so the attached patch slightly
> restructures the code to use that, and deletes the block of code that
> does not check the return value.
> 
> The second assignment of block_len = byte_len & ~(SECTOR_SIZE - 1);
> (after the read of the main block) is unnecessary since the same
> assignment has already been made 21 lines above.
> 
> The first change in the patch is purely cosmetic, in that it simply
> changes an error message to make it consistent with the other error
> messages in the function.
> 
> --- orig/fs/ext2/dev.c	2010-01-03 01:04:57.000000000 +0000
> +++ fs/ext2/dev.c       2010-01-03 01:08:43.000000000 +000

Signed-off-by: line missing. 

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
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
Unser Kopf ist rund, damit das Denken die Richtung wechseln kann.
                                                   -- Francis Picabia


More information about the U-Boot mailing list