]> Gentwo Git Trees - linux/.git/commit
mtd: lpddr_cmds: fix signed shifts in lpddr_cmds
authorIvan Stepchenko <sid@itb.spb.ru>
Fri, 21 Nov 2025 11:54:46 +0000 (14:54 +0300)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Sat, 29 Nov 2025 12:50:19 +0000 (13:50 +0100)
commitc909fec69f84b39e63876c69b9df2c178c6b76ba
tree7e1f4820d71bf345988b3c64194f36ea314d406f
parent1cce5a5ecafeb8a79aa9165cf134c97da7bbc7db
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: c68264711ca6 ("[MTD] LPDDR Command set driver")
Signed-off-by: Ivan Stepchenko <sid@itb.spb.ru>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
drivers/mtd/lpddr/lpddr_cmds.c