linux-uconsole/drivers/pinctrl/uniphier
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
..
Kconfig pinctrl: uniphier: add UniPhier PXs3 pinctrl driver 2017-08-14 15:01:00 +02:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pinctrl-uniphier-core.c treewide: Use struct_size() for devm_kmalloc() and friends 2018-06-06 11:15:43 -07:00
pinctrl-uniphier-ld4.c pinctrl: uniphier: add UART hardware flow control pin-mux settings 2018-03-27 15:14:43 +02:00
pinctrl-uniphier-ld6b.c pinctrl: uniphier: add UART hardware flow control pin-mux settings 2018-03-27 15:14:43 +02:00
pinctrl-uniphier-ld11.c pinctrl: uniphier: add UART hardware flow control pin-mux settings 2018-03-27 15:14:43 +02:00
pinctrl-uniphier-ld20.c pinctrl: uniphier: add UART hardware flow control pin-mux settings 2018-03-27 15:14:43 +02:00
pinctrl-uniphier-pro4.c pinctrl: uniphier: add UART hardware flow control pin-mux settings 2018-03-27 15:14:43 +02:00
pinctrl-uniphier-pro5.c pinctrl: uniphier: add UART hardware flow control pin-mux settings 2018-03-27 15:14:43 +02:00
pinctrl-uniphier-pxs2.c pinctrl: uniphier: add UART hardware flow control pin-mux settings 2018-03-27 15:14:43 +02:00
pinctrl-uniphier-pxs3.c pinctrl: uniphier: add UART hardware flow control pin-mux settings 2018-03-27 15:14:43 +02:00
pinctrl-uniphier-sld8.c pinctrl: uniphier: add UART hardware flow control pin-mux settings 2018-03-27 15:14:43 +02:00
pinctrl-uniphier.h pinctrl: uniphier: include <linux/build_bug.h> instead of <linux/bug.h> 2017-09-12 11:18:17 +02:00