[PATCH v2] mmc: fix signed vs unsigned compare in read check in _spl_load()

Tom Rini trini at konsulko.com
Wed Aug 28 20:26:57 CEST 2024


On Wed, 31 Jul 2024 09:09:00 -0400, Franco Venturi wrote:

> Fix signed vs unsigned compare in read check in _spl_load()
> 
> Issue: when info->read() returns a negative value because of an error,
>        the comparison of 'read' (signed) with 'sizeof(*header)'
>        (unsigned silently converts the negative value into a very
>        large unsigned value and the check on the error condition
>        always return false, i.e. the error is not detected
> Symptoms: if spl_load_image_fat() is unable to find the file 'uImage',
>           the SPL phase of the boot process just hangs after displaying
>           the following line:
>           Trying to boot from MMC1
> Fix: cast 'sizeof(*header)' to int so the compare is now between
>      signed types
> Reference: https://stackoverflow.com/questions/17293749/sizeof-operator-in-if-statement
> 
> [...]

Applied to u-boot/next, thanks!

-- 
Tom




More information about the U-Boot mailing list