mirror of
https://github.com/torvalds/linux.git
synced 2025-11-09 13:10:19 +02:00
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
|
||
|---|---|---|
| .. | ||
| amd76xrom.c | ||
| cfi_flagadm.c | ||
| ck804xrom.c | ||
| dc21285.c | ||
| esb2rom.c | ||
| ichxrom.c | ||
| impa7.c | ||
| Kconfig | ||
| l440gx.c | ||
| lantiq-flash.c | ||
| Makefile | ||
| map_funcs.c | ||
| netsc520.c | ||
| nettel.c | ||
| pci.c | ||
| pcmciamtd.c | ||
| physmap-bt1-rom.c | ||
| physmap-bt1-rom.h | ||
| physmap-core.c | ||
| physmap-gemini.c | ||
| physmap-gemini.h | ||
| physmap-ixp4xx.c | ||
| physmap-ixp4xx.h | ||
| physmap-versatile.c | ||
| physmap-versatile.h | ||
| pismo.c | ||
| plat-ram.c | ||
| pxa2xx-flash.c | ||
| sa1100-flash.c | ||
| sbc_gxx.c | ||
| sc520cdp.c | ||
| scb2_flash.c | ||
| scx200_docflash.c | ||
| solutionengine.c | ||
| sun_uflash.c | ||
| ts5500_flash.c | ||
| tsunami_flash.c | ||
| uclinux.c | ||
| vmu-flash.c | ||