linux/drivers/soc
Kees Cook 0ed2dd03b9 treewide: Use struct_size() for devm_kmalloc() and friends
Replaces open-coded struct size calculations with struct_size() for
devm_*, f2fs_*, and sock_* allocations. Automatically generated (and
manually adjusted) from the following Coccinelle script:

// Direct reference to struct field.
@@
identifier alloc =~ "devm_kmalloc|devm_kzalloc|sock_kmalloc|f2fs_kmalloc|f2fs_kzalloc";
expression HANDLE;
expression GFP;
identifier VAR, ELEMENT;
expression COUNT;
@@

- alloc(HANDLE, sizeof(*VAR) + COUNT * sizeof(*VAR->ELEMENT), GFP)
+ alloc(HANDLE, struct_size(VAR, ELEMENT, COUNT), GFP)

// mr = kzalloc(sizeof(*mr) + m * sizeof(mr->map[0]), GFP_KERNEL);
@@
identifier alloc =~ "devm_kmalloc|devm_kzalloc|sock_kmalloc|f2fs_kmalloc|f2fs_kzalloc";
expression HANDLE;
expression GFP;
identifier VAR, ELEMENT;
expression COUNT;
@@

- alloc(HANDLE, sizeof(*VAR) + COUNT * sizeof(VAR->ELEMENT[0]), GFP)
+ alloc(HANDLE, struct_size(VAR, ELEMENT, COUNT), GFP)

// Same pattern, but can't trivially locate the trailing element name,
// or variable name.
@@
identifier alloc =~ "devm_kmalloc|devm_kzalloc|sock_kmalloc|f2fs_kmalloc|f2fs_kzalloc";
expression HANDLE;
expression GFP;
expression SOMETHING, COUNT, ELEMENT;
@@

- alloc(HANDLE, sizeof(SOMETHING) + COUNT * sizeof(ELEMENT), GFP)
+ alloc(HANDLE, CHECKME_struct_size(&SOMETHING, ELEMENT, COUNT), GFP)

Signed-off-by: Kees Cook <keescook@chromium.org>
2018-06-06 11:15:43 -07:00
..
actions treewide: Use struct_size() for devm_kmalloc() and friends 2018-06-06 11:15:43 -07:00
amlogic amlogic: meson-gx-socinfo: Update soc ids 2018-03-19 16:40:26 -07:00
atmel drivers: soc: atmel: Add basic support for new sama5d2 SiPs 2017-09-17 19:45:59 +02:00
bcm soc: bcm: raspberrypi-power: Fix use of __packed 2018-04-16 15:15:23 -07:00
dove License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
fsl soc/fsl/qbman: fix issue in qman_delete_cgr_safe() 2018-03-14 13:16:23 -04:00
gemini soc: Add SoC driver for Gemini 2018-01-04 17:01:53 +01:00
imx i.MX drivers update for 4.17: 2018-03-15 16:23:33 +01:00
lantiq MIPS: lantiq: Add a GPHY driver which uses the RCU syscon-mfd 2017-09-04 21:19:02 +02:00
mediatek soc: mediatek: update power domain data of MT2712 2018-03-19 02:29:05 +01:00
qcom remoteproc updates for v4.17 2018-04-10 12:09:27 -07:00
renesas soc: renesas: rcar-rst: Add support for R-Car M3-N 2018-02-23 15:55:01 +01:00
rockchip treewide: Use struct_size() for devm_kmalloc() and friends 2018-06-06 11:15:43 -07:00
samsung The large diff this time around is from the addition of a new clk driver 2018-04-13 15:51:06 -07:00
sunxi drivers: soc: sunxi: add support for A64 and its SRAM C 2017-08-18 14:30:21 +08:00
tegra soc/tegra: pmc: Use the new reset APIs to manage reset controllers 2018-03-19 09:42:39 +01:00
ti soc: ti: Add pm33xx driver for basic suspend support 2018-02-27 08:53:46 -08:00
ux500 ARM: ux500: move soc_id driver to drivers/soc 2016-07-12 11:24:09 +02:00
versatile soc: versatile: remove unnecessary static in realview_soc_probe() 2017-08-16 22:28:27 +02:00
xilinx soc: xilinx: Fix Kconfig alignment 2018-01-16 15:50:21 +01:00
zte soc: zte: Restrict SOC_ZTE to ARCH_ZX or COMPILE_TEST 2017-07-27 13:12:34 +02:00
Kconfig soc: xilinx: Create folder structure for soc specific drivers 2018-01-08 13:42:39 +01:00
Makefile ARM: SoC driver updates for 4.16 2018-02-01 16:35:31 -08:00