linux/drivers/input/keyboard
Gustavo A. R. Silva 002cdb95dc Input: gpio_keys - use struct_size() in devm_kzalloc()
One of the more common cases of allocation size calculations is finding
the size of a structure that has a zero-sized array at the end, along
with memory for some number of elements for that array. For example:

struct gpio_keys_drvdata {
	...
        struct gpio_button_data data[0];
};

size = sizeof(struct gpio_keys_drvdata) + count * sizeof(struct gpio_button_data);
instance = devm_kzalloc(dev, size, GFP_KERNEL);

Instead of leaving these open-coded and prone to type mistakes, we can
now use the new struct_size() helper:

instance = devm_kzalloc(dev, struct_size(instance, data, count), GFP_KERNEL);

Notice that, in this case, variable size is not necessary, hence it
is removed.

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2019-06-22 23:36:24 -07:00
..
adc-keys.c
adp5520-keys.c
adp5588-keys.c
adp5589-keys.c Input: mark expected switch fall-throughs 2018-08-08 11:23:27 -07:00
amikbd.c Input: stop telling users to snail-mail Vojtech 2018-07-26 17:04:37 -07:00
atakbd.c Input: atakbd - fix Atari CapsLock behaviour 2018-09-18 15:28:07 -07:00
atkbd.c Input: i8042 - signal wakeup from atkbd/psmouse 2019-04-04 11:51:26 -07:00
bcm-keypad.c
cap11xx.c Input: cap11xx - switch to using set_brightness_blocking() 2019-02-09 08:56:56 -08:00
clps711x-keypad.c treewide: devm_kzalloc() -> devm_kcalloc() 2018-06-12 16:19:22 -07:00
cros_ec_keyb.c Input: cros_ec_keyb - fix button/switch capability reports 2018-11-12 11:52:04 -08:00
davinci_keyscan.c input: davinci_keyscan: remove unnecessary includes 2019-02-19 19:39:15 +05:30
dlink-dir685-touchkeys.c
ep93xx_keypad.c
goldfish_events.c Input: goldfish_events - fix checkpatch warnings 2018-06-04 13:36:26 -07:00
gpio_keys_polled.c Input: gpio_keys_polled - use struct_size() in devm_kzalloc() 2019-06-22 23:34:57 -07:00
gpio_keys.c Input: gpio_keys - use struct_size() in devm_kzalloc() 2019-06-22 23:36:24 -07:00
hil_kbd.c
hilkbd.c Update email address 2018-09-29 22:47:48 -04:00
hpps2atkbd.h
imx_keypad.c Input: imx_keypad - use devm_platform_ioremap_resource() to simplify code 2019-05-20 22:45:17 -07:00
ipaq-micro-keys.c
jornada680_kbd.c
jornada720_kbd.c
Kconfig Linux 5.1 2019-05-10 11:43:46 -07:00
lkkbd.c
lm8323.c
lm8333.c
locomokbd.c
lpc32xx-keys.c
Makefile Input: qt1050 - add Microchip AT42QT1050 support 2019-05-07 14:12:43 -07:00
maple_keyb.c
matrix_keypad.c Input: matrix_keypad - use flush_delayed_work() 2019-02-09 09:00:03 -08:00
max7359_keypad.c
mcs_touchkey.c Input: mcs_touchkey - use struct_size() in kzalloc() 2019-01-13 22:48:55 -08:00
mpr121_touchkey.c
mtk-pmic-keys.c Input: mtk-pmic-keys - remove duplicated include from mtk-pmic-keys.c 2019-01-13 22:49:31 -08:00
newtonkbd.c Input: stop telling users to snail-mail Vojtech 2018-07-26 17:04:37 -07:00
nomadik-ske-keypad.c Input: nomadik-ske-keypad - fix a loop timeout test 2018-12-21 00:52:37 -08:00
nspire-keypad.c
omap4-keypad.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input 2018-12-21 09:09:30 -08:00
omap-keypad.c
opencores-kbd.c
pmic8xxx-keypad.c
pxa27x_keypad.c
pxa930_rotary.c
qt1050.c Input: qt1050 - add Microchip AT42QT1050 support 2019-05-07 14:12:43 -07:00
qt1070.c
qt2160.c Merge branch 'next' into for-linus 2019-03-03 23:14:44 -08:00
samsung-keypad.c treewide: devm_kzalloc() -> devm_kcalloc() 2018-06-12 16:19:22 -07:00
sh_keysc.c
snvs_pwrkey.c Linux 5.1 2019-05-10 11:43:46 -07:00
spear-keyboard.c
st-keyscan.c Input: st-keyscan - fix potential zalloc NULL dereference 2019-02-16 21:44:02 -08:00
stmpe-keypad.c
stowaway.c Input: stop telling users to snail-mail Vojtech 2018-07-26 17:04:37 -07:00
sun4i-lradc-keys.c Input: sun4i-a10-lradc-keys - add support for A83T 2019-04-04 11:51:29 -07:00
sunkbd.c Input: stop telling users to snail-mail Vojtech 2018-07-26 17:04:37 -07:00
tc3589x-keypad.c
tca6416-keypad.c Input: tca6416-keypad - use struct_size() in kzalloc() 2019-01-13 22:48:54 -08:00
tca8418_keypad.c Input: tca8418 - remove set but not used variable 'max_keys' 2019-05-27 19:01:42 -07:00
tegra-kbc.c
tm2-touchkey.c Input: tm2-touchkey - acknowledge that setting brightness is a blocking call 2019-02-07 23:41:12 -08:00
twl4030_keypad.c
w90p910_keypad.c
xtkbd.c Input: stop telling users to snail-mail Vojtech 2018-07-26 17:04:37 -07:00