linux/drivers/mtd/lpddr
Ivan Stepchenko c909fec69f mtd: lpddr_cmds: fix signed shifts in lpddr_cmds
There are several places where a value of type 'int' is shifted by
lpddr->chipshift. lpddr->chipshift is derived from QINFO geometry and
might reach 31 when QINFO reports a 2 GiB size - the maximum supported by
LPDDR(1) compliant chips. This may cause unexpected sign-extensions when
casting the integer value to the type of 'unsigned long'.

Use '1UL << lpddr->chipshift' and cast 'j' to unsigned long before
shifting so the computation is performed at the destination width.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: c68264711c ("[MTD] LPDDR Command set driver")
Signed-off-by: Ivan Stepchenko <sid@itb.spb.ru>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-11-29 13:50:19 +01:00
..
Kconfig
Makefile
lpddr2_nvm.c mtd: Switch back to struct platform_driver::remove() 2024-10-21 11:58:07 +02:00
lpddr_cmds.c mtd: lpddr_cmds: fix signed shifts in lpddr_cmds 2025-11-29 13:50:19 +01:00
qinfo_probe.c mtd: lpddr: Remove space before newline 2025-09-11 17:34:15 +02:00