linux/drivers/mtd/devices
Alexander Usyskin 721bd22bcf mtd: intel-dg: Fix accessing regions before setting nregions
[ Upstream commit 779c59274d ]

The regions array is counted by nregions, but it's set only after
accessing it:

[] UBSAN: array-index-out-of-bounds in drivers/mtd/devices/mtd_intel_dg.c:750:15
[] index 0 is out of range for type '<unknown> [*]'

Fix it by also fixing an undesired behavior: the loop silently ignores
ENOMEM and continues setting the other entries.

CC: Gustavo A. R. Silva <gustavoars@kernel.org>
CC: Raag Jadav <raag.jadav@intel.com>
Reported-by: Jani Partanen <jiipee@sotapeli.fi>
Closes: https://lore.kernel.org/all/caca6c67-4f1d-49f1-948f-e63b6b937b29@sotapeli.fi
Fixes: ceb5ab3cb6 ("mtd: add driver for intel graphics non-volatile memory device")
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Reviewed-by: Raag Jadav <raag.jadav@intel.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2026-02-26 14:59:25 -08:00
..
bcm47xxsflash.c mtd: Switch back to struct platform_driver::remove() 2024-10-21 11:58:07 +02:00
bcm47xxsflash.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
block2mtd.c block2mtd: prevent direct access of bd_inode 2024-05-03 02:36:21 -04:00
docg3.c mtd: Switch back to struct platform_driver::remove() 2024-10-21 11:58:07 +02:00
docg3.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
Kconfig mtd: MTD_INTEL_DG should depend on DRM_I915 or DRM_XE 2025-08-28 14:22:48 +02:00
Makefile mtd: add driver for intel graphics non-volatile memory device 2025-06-23 13:14:49 -04:00
mchp23k256.c mtd: mchp23k256: drop unneeded MODULE_ALIAS 2024-04-15 12:06:06 +02:00
mchp48l640.c mtd: mchp48l640: Use str_enable_disable() in mchp48l640_write_prepare() 2025-03-18 17:18:51 +01:00
ms02-nv.c mtd: devices: Remove superfluous "break" 2021-05-26 10:58:26 +02:00
ms02-nv.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
mtd_dataflash.c mtd: dataflash: Follow renaming of SPI "master" to "controller" 2024-02-08 11:54:44 +00:00
mtd_intel_dg.c mtd: intel-dg: Fix accessing regions before setting nregions 2026-02-26 14:59:25 -08:00
mtdram.c mtd: mtdram: Expose module parameters 2019-01-08 12:42:57 +01:00
phram.c mtd: phram: Add the kernel lock down check 2024-12-05 11:11:44 +01:00
pmc551.c mtd: pmc551: Remove set but not used variable 'soff_lo' 2019-09-15 23:51:07 +02:00
powernv_flash.c mtd: Switch back to struct platform_driver::remove() 2024-10-21 11:58:07 +02:00
serial_flash_cmds.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 420 2019-06-05 17:37:15 +02:00
slram.c mtd: slram: insert break after errors in parsing the map 2024-08-23 19:25:46 +02:00
spear_smi.c mtd: Switch back to struct platform_driver::remove() 2024-10-21 11:58:07 +02:00
sst25l.c spi: make remove callback a void function 2022-02-09 13:00:45 +00:00
st_spi_fsm.c mtd: st_spi_fsm: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() 2025-01-15 19:10:29 +01:00