]> 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>
Thu, 18 Dec 2025 12:55:13 +0000 (13:55 +0100)
commit6e1acbe563ddd0e477a1b5bcc548952f9f37bbdc
treed6face54194c5ce0acceeb2e1139b2155bf764d8
parentbd8bb75d859a1c0b4bc2263c14ea4bd7c9148c3f
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