linux/drivers/mtd/maps
Erick Archer 3ef4600f12 mtd: maps: sa1100-flash: Prefer struct_size over open coded arithmetic
This is an effort to get rid of all multiplications from allocation
functions in order to prevent integer overflows [1][2].

As the "info" variable is a pointer to "struct sa_info" and this
structure ends in a flexible array:

struct sa_info {
	[...]
	struct sa_subdev_info	subdev[];
};

the preferred way in the kernel is to use the struct_size() helper to
do the arithmetic instead of the calculation "size + size * count" in
the kzalloc() function.

This way, the code is more readable and safer.

This code was detected with the help of Coccinelle, and audited and
modified manually.

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [1]
Link: https://github.com/KSPP/linux/issues/160 [2]
Signed-off-by: Erick Archer <erick.archer@outlook.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/AS8PR02MB7237AC633B0D1D2EBD3C40E98B392@AS8PR02MB7237.eurprd02.prod.outlook.com
2024-04-09 08:35:37 +02:00
..
amd76xrom.c mtd: amd76xrom: remove unnecessary oom message 2021-06-11 20:44:18 +02:00
cfi_flagadm.c mtd: constify mtd_partition 2017-11-06 23:26:01 +01:00
ck804xrom.c mtd: ck804xrom: remove unnecessary oom message 2021-06-11 20:44:14 +02:00
dc21285.c
esb2rom.c mtd: esb2rom: remove unnecessary oom message 2021-06-11 20:44:07 +02:00
ichxrom.c mtd: ichxrom: remove unnecessary oom message 2021-06-11 20:43:58 +02:00
impa7.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
Kconfig mtd: Remove support for Carillo Ranch driver 2024-02-26 11:29:36 +01:00
l440gx.c remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
lantiq-flash.c mtd: maps: lantiq-flash: Convert to platform remove callback returning void 2023-10-16 10:56:48 +02:00
Makefile mtd: Remove support for Carillo Ranch driver 2024-02-26 11:29:36 +01:00
map_funcs.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
netsc520.c remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
nettel.c remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
pci.c mtd: convert comma to semicolon 2021-02-01 18:58:38 +01:00
pcmciamtd.c mtd: maps: pcmciamtd: fix possible sleep-in-atomic-context bugs in pcmciamtd_set_vpp() 2020-01-27 16:55:02 +01:00
physmap-bt1-rom.c mtd: Explicitly include correct DT includes 2023-07-27 17:03:41 +02:00
physmap-bt1-rom.h mtd: physmap: Add Baikal-T1 physically mapped ROM support 2020-10-02 09:08:22 +02:00
physmap-core.c mtd: maps: physmap-core: fix flash size larger than 32-bit 2024-02-26 11:26:21 +01:00
physmap-gemini.c mtd: Explicitly include correct DT includes 2023-07-27 17:03:41 +02:00
physmap-gemini.h mtd: maps: Rename physmap_of_{versatile, gemini} into physmap-{versatile, gemini} 2018-11-05 22:24:29 +01:00
physmap-ixp4xx.c mtd: Explicitly include correct DT includes 2023-07-27 17:03:41 +02:00
physmap-ixp4xx.h mtd: Explicitly include correct DT includes 2023-07-27 17:03:41 +02:00
physmap-versatile.c mtd: maps: fix -Wvoid-pointer-to-enum-cast warning 2023-08-18 16:38:54 +02:00
physmap-versatile.h mtd: maps: Rename physmap_of_{versatile, gemini} into physmap-{versatile, gemini} 2018-11-05 22:24:29 +01:00
pismo.c mtd: maps: pismo: Switch back to use i2c_driver's .probe() 2023-06-19 10:26:03 +02:00
plat-ram.c mtd: maps: plat-ram: Convert to platform remove callback returning void 2023-10-16 10:56:48 +02:00
pxa2xx-flash.c mtd: maps: pxa2xx-flash: Convert to platform remove callback returning void 2023-10-16 10:56:48 +02:00
sa1100-flash.c mtd: maps: sa1100-flash: Prefer struct_size over open coded arithmetic 2024-04-09 08:35:37 +02:00
sbc_gxx.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
sc520cdp.c mtd: Replace HTTP links with HTTPS ones 2020-08-02 22:17:19 +02:00
scb2_flash.c remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
scx200_docflash.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
solutionengine.c mtd/maps: fix solutionengine.c printk format warnings 2018-07-24 22:43:10 +02:00
sun_uflash.c mtd: maps: sun_uflash: Declare uflash_devinit static 2024-03-08 21:20:23 +01:00
ts5500_flash.c remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
tsunami_flash.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
uclinux.c mtd: maps: Make uclinux_ram_map static 2019-05-06 21:47:01 +02:00
vmu-flash.c mtd: maps: vmu-flash: Fix the (mtd core) switch to ref counters 2023-12-14 16:43:17 +01:00