linux/sound
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
..
ac97 ALSA: ac97: kconfig: Remove select of undefined symbol AC97 2018-02-12 08:16:39 +01:00
aoa
arm
atmel
core treewide: Use struct_size() for kmalloc()-family 2018-06-06 11:15:43 -07:00
drivers ALSA: aloop: Add missing cable lock to ctl API callbacks 2018-04-30 10:06:48 +02:00
firewire ALSA: dice: fix kernel NULL pointer dereference due to invalid calculation for array index 2018-04-29 09:06:39 +02:00
hda ALSA: hda: Copying sync power state helper to core 2018-02-12 13:59:39 +01:00
i2c
isa ALSA: gus: Delete an error message for a failed memory allocation in snd_gf1_dma_transfer_block() 2017-11-29 09:29:36 +01:00
mips ALSA: sgio2audio: Improve a size determination in snd_sgio2audio_create() 2017-11-29 09:29:31 +01:00
oss vfs: do bulk POLL* -> EPOLL* replacement 2018-02-11 14:34:03 -08:00
parisc
pci ALSA: hda - Fix incorrect usage of IS_REACHABLE() 2018-04-27 17:17:35 +02:00
pcmcia
ppc
sh
soc treewide: Use struct_size() for devm_kmalloc() and friends 2018-06-06 11:15:43 -07:00
sparc
spi
synth
usb ALSA: usx2y: Change return type to vm_fault_t 2018-04-25 08:15:20 +02:00
x86 ALSA: x86: Fix potential crash at error path 2018-02-28 08:46:00 +01:00
ac97_bus.c
Kconfig
last.c
Makefile
sound_core.c sound: Remove leftover msnd init declarations 2018-01-11 17:10:34 +01:00