linux/drivers/mtd
Ivan Stepchenko 0d39bd3ef7 mtd: lpddr_cmds: fix signed shifts in lpddr_cmds
[ Upstream commit c909fec69f ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2026-01-19 13:09:36 +01:00
..
chips mtd: cfi_cmdset_0001: Byte swap OTP info 2023-11-28 16:56:31 +00:00
devices mtd: powernv: Add check devm_kasprintf() returned value 2024-10-17 15:10:50 +02:00
hyperbus mtd: hyperbus: hbmc-am654: fix an OF node reference leak 2025-03-13 12:50:09 +01:00
lpddr mtd: lpddr_cmds: fix signed shifts in lpddr_cmds 2026-01-19 13:09:36 +01:00
maps mtd: maps: physmap-core: fix flash size larger than 32-bit 2024-03-26 18:21:29 -04:00
nand mtd: rawnand: cadence: fix DMA device NULL pointer dereference 2025-12-07 06:09:30 +09:00
parsers mtd: partitions: redboot: Added conversion of operands to a larger type 2024-07-05 09:14:43 +02:00
spi-nor Revert "mtd: spi-nor: core: replace dummy buswidth from addr to data" 2025-01-23 17:15:59 +01:00
tests mtd: make mtd_test.c a separate module 2024-08-19 05:45:05 +02:00
ubi ubi: fastmap: Fix duplicate slab cache names while attaching 2024-12-14 19:51:20 +01:00
ftl.c mtd: fix possible integer overflow in erase_xfer() 2025-08-28 16:24:09 +02:00
inftlcore.c mtd: inftlcore: Add error check for inftl_read_oob() 2025-05-02 07:44:04 +02:00
inftlmount.c mtd: inftl: remove unnecessary oom message 2021-06-11 20:44:21 +02:00
Kconfig mtdblock: Add comment about UBI block devices 2021-08-06 22:05:13 +02:00
Makefile mtd: Support kmsg dumper based on pstore/blk 2020-05-31 19:49:01 -07:00
mtd_blkdevs.c mtd: Fix gluebi NULL pointer dereference caused by ftl notifier 2024-01-25 14:52:34 -08:00
mtdblock.c mtdblock: tolerate corrected bit-flips 2023-04-20 12:13:52 +02:00
mtdblock_ro.c mtdblock: Warn if added for a NAND device 2021-08-17 18:41:59 +02:00
mtdchar.c mtd: add OTP (one-time-programmable) erase ioctl 2021-03-28 19:24:54 +02:00
mtdconcat.c mtd: mtdconcat: Check _read, _write callbacks existence before assignment 2021-08-17 18:43:33 +02:00
mtdcore.c mtd: core: Report error if first mtd_otp_size() call fails in mtd_otp_nvmem_add() 2024-06-16 13:39:27 +02:00
mtdcore.h mtd: Provide fs_context-aware mount_mtd() replacement 2019-09-05 14:34:23 -04:00
mtdoops.c mtd: mtdoops: remove unnecessary oom message 2021-06-11 20:43:46 +02:00
mtdpart.c mtd: Fixed breaking list in __mtd_del_partition. 2022-01-27 11:02:48 +01:00
mtdpstore.c mtd: Replace kcalloc() with devm_kcalloc() 2025-05-02 07:44:02 +02:00
mtdsuper.c block: remove i_bdev 2020-12-01 14:53:39 -07:00
mtdswap.c mtd: mtdswap: Use module_mtd_blktrans to register driver 2021-03-11 09:37:48 +01:00
nftlcore.c mtd: nftlcore: remove set but rewrite variables 2021-05-10 12:11:46 +02:00
nftlmount.c mtd: nftl: remove unnecessary oom message 2021-06-11 20:43:26 +02:00
rfd_ftl.c mtd/rfd_ftl: don't cast away the type when calling add_mtd_blktrans_dev 2021-08-23 10:01:06 +02:00
sm_ftl.c mtd: sm_ftl: Fix deadlock caused by cancel_work_sync in sm_release 2022-08-17 14:23:40 +02:00
sm_ftl.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
ssfdc.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00