kernel_optimize_test/drivers/clk/davinci
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
..
da8xx-cfgchip.c treewide: Use struct_size() for devm_kmalloc() and friends 2018-06-06 11:15:43 -07:00
Makefile clk: davinci: New driver for TI DA8XX CFGCHIP clocks 2018-03-20 10:16:26 -07:00
pll-da830.c
pll-da850.c clk: davinci: Add platform information for TI DA850 PLL 2018-03-20 10:16:26 -07:00
pll-dm355.c clk: davinci: Add platform information for TI DM355 PLL 2018-03-20 10:16:26 -07:00
pll-dm365.c clk: davinci: Add platform information for TI DM365 PLL 2018-03-20 10:16:26 -07:00
pll-dm644x.c clk: davinci: Add platform information for TI DM644x PLL 2018-03-20 10:16:26 -07:00
pll-dm646x.c clk: davinci: Add platform information for TI DM646x PLL 2018-03-20 10:16:26 -07:00
pll.c clk: davinci: Remove redundant dev_err calls 2018-03-23 09:44:45 -07:00
pll.h clk: davinci: Add platform information for TI DM646x PLL 2018-03-20 10:16:26 -07:00
psc-da830.c clk: davinci: Add platform information for TI DA830 PSC 2018-03-20 10:16:26 -07:00
psc-da850.c clk: davinci: add a reset lookup table for psc0 2018-04-06 13:37:19 -07:00
psc-dm355.c clk: davinci: Add platform information for TI DM355 PSC 2018-03-20 10:16:26 -07:00
psc-dm365.c clk: davinci: Add platform information for TI DM365 PSC 2018-03-20 10:16:26 -07:00
psc-dm644x.c clk: davinci: Add platform information for TI DM644x PSC 2018-03-20 10:16:26 -07:00
psc-dm646x.c clk: davinci: Add platform information for TI DM646x PSC 2018-03-20 10:16:26 -07:00
psc.c clk: davinci: add a reset lookup table for psc0 2018-04-06 13:37:19 -07:00
psc.h clk: davinci: Add platform information for TI DM646x PSC 2018-03-20 10:16:26 -07:00