]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 19 Jan 2026 12:09:36 +0000 (13:09 +0100)
commit0d39bd3ef77a7c333a2f8c0e0843fc5bd7dd26e5
tree5d7b9eb2df53b0ee2bc8c5adfee6085c0dcdff63
parent1d6155900a69523a38cb5694acca20c0bd4be1a7
mtd: lpddr_cmds: fix signed shifts in lpddr_cmds

[ Upstream commit c909fec69f84b39e63876c69b9df2c178c6b76ba ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/mtd/lpddr/lpddr_cmds.c