linux/drivers/clk/mvebu
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
..
ap806-system-controller.c clk: mvebu: ap806: introduce a new binding 2017-06-01 12:03:21 +09:00
armada-37xx-periph.c treewide: Use struct_size() for devm_kmalloc() and friends 2018-06-06 11:15:43 -07:00
armada-37xx-tbg.c treewide: Use struct_size() for devm_kmalloc() and friends 2018-06-06 11:15:43 -07:00
armada-37xx-xtal.c clk: mvebu: Add the xtal clock for Armada 3700 SoC 2016-08-15 14:07:04 -07:00
armada-38x.c clk: mvebu: armada-38x: add support for missing clocks 2018-03-19 13:53:57 -07:00
armada-39x.c clk: mvebu: armada-39x: add clk description for supported interfaces 2016-08-12 18:20:01 -07:00
armada-370.c
armada-375.c
armada-xp.c clk: mvebu: Expand mv98dx3236-core-clock support 2017-02-10 09:21:30 -08:00
clk-corediv.c clk: mvebu: support for 98DX3236 SoC 2017-01-27 10:48:03 -08:00
clk-cpu.c clk: mvebu: Use kcalloc() in of_cpu_clk_setup() 2017-04-21 19:49:13 -07:00
common.c clk: mvebu: Use kcalloc() in two functions 2017-04-21 19:49:34 -07:00
common.h
cp110-system-controller.c clk: mvebu: cp110: Fix clock tree representation 2018-03-19 13:10:50 -07:00
dove-divider.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
dove-divider.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
dove.c
Kconfig clk: mvebu: Add the xtal clock for Armada 3700 SoC 2016-08-15 14:07:04 -07:00
kirkwood.c
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
mv98dx3236.c clk: mvebu: Expand mv98dx3236-core-clock support 2017-02-10 09:21:30 -08:00
orion.c clk: mvebu: Add clk support for the orion5x SoC mv88f5181 2016-09-21 11:49:09 +02:00