aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/lib/code-patching.c
diff options
context:
space:
mode:
authorErick Archer <[email protected]>2024-03-30 17:55:35 +0000
committerMiquel Raynal <[email protected]>2024-04-09 06:35:37 +0000
commit3ef4600f12269d489933b3835fe8d43621e4ee6c (patch)
tree0684ea356ea4d7c7e8c56309e9ebce10bfd20524 /arch/powerpc/lib/code-patching.c
parentmtd: core: Align comment with an action in mtd_otp_nvmem_add() (diff)
downloadkernel-3ef4600f12269d489933b3835fe8d43621e4ee6c.tar.gz
kernel-3ef4600f12269d489933b3835fe8d43621e4ee6c.zip
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 <[email protected]> Signed-off-by: Miquel Raynal <[email protected]> Link: https://lore.kernel.org/linux-mtd/AS8PR02MB7237AC633B0D1D2EBD3C40E98B392@AS8PR02MB7237.eurprd02.prod.outlook.com
Diffstat (limited to 'arch/powerpc/lib/code-patching.c')
0 files changed, 0 insertions, 0 deletions