[PATCH] mci: fix wrong sd/mmc/emmc card size computation for arch where char is signed

Sascha Hauer s.hauer at pengutronix.de
Tue Sep 15 03:33:26 EDT 2020


On Mon, Sep 14, 2020 at 06:02:08PM +0200, Yann Sionneau wrote:
> char type can be either signed or unsigned according to C standard.
> If your arch has signed char, this kind of computation will end up wrong
> because of sign extension:
> 
> https://git.pengutronix.de/cgit/barebox/tree/drivers/mci/mci-core.c#n869
> 
> mci->capacity = mci->ext_csd[EXT_CSD_SEC_COUNT] << 0 |
> 		mci->ext_csd[EXT_CSD_SEC_COUNT + 1] << 8 |
> 		mci->ext_csd[EXT_CSD_SEC_COUNT + 2] << 16 |
> 		mci->ext_csd[EXT_CSD_SEC_COUNT + 3] << 24;
> 
> Turning the ext_csd field into u8 * fixes the issue.
> 
> Signed-off-by: Yann Sionneau <ysionneau at kalray.eu>
> ---
>  include/mci.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list