linux/drivers/misc
Gustavo A. R. Silva 9ae9d9bfb7 eeprom: at24: 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 foo {
    int stuff;
    struct boo entry[];
};

size = sizeof(struct foo) + count * sizeof(struct boo);
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, entry, count), GFP_KERNEL);

Notice that, in this case, variable at24_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: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2019-05-31 09:06:52 +02:00
..
altera-stapl
c2port
cardreader Char/Misc patches for 5.2-rc1 - part 2 2019-05-07 13:39:22 -07:00
cb710
cxl powerpc/mm/hash64: Map all the kernel regions in the same 0xc range 2019-04-21 23:12:39 +10:00
echo
eeprom eeprom: at24: use struct_size() in devm_kzalloc() 2019-05-31 09:06:52 +02:00
genwqe mm/gup: change GUP fast to use flags rather than a write 'bool' 2019-05-14 09:47:46 -07:00
habanalabs habanalabs: Update CPU DMA memory label name 2019-05-02 15:37:19 +03:00
ibmasm
lis3lv02d
lkdtm
mei Char/Misc patches for 5.2-rc1 - part 2 2019-05-07 13:39:22 -07:00
mic x86/pci: Clean up usage of X86_DEV_DMA_OPS 2019-04-24 13:12:05 +02:00
ocxl ocxl: Fix return value check in afu_ioctl() 2019-05-06 20:21:56 +10:00
sgi-gru
sgi-xp mm: replace all open encodings for NUMA_NO_NODE 2019-03-05 21:07:14 -08:00
ti-st
vmw_vmci mm/gup: change GUP fast to use flags rather than a write 'bool' 2019-05-14 09:47:46 -07:00
ad525x_dpot-i2c.c
ad525x_dpot-spi.c
ad525x_dpot.c
ad525x_dpot.h
apds990x.c
apds9802als.c
atmel_tclib.c misc: atmel_tclib: Do not probe already used TCBs 2019-05-02 21:55:58 +02:00
atmel-ssc.c
bh1770glc.c
cs5535-mfgpt.c
ds1682.c
dummy-irq.c
enclosure.c
fastrpc.c Merge 5.1-rc6 into char-misc-next 2019-04-21 23:14:47 +02:00
fsa9480.c
hmc6352.c
hpilo.c misc: hpilo: Do not claim unsupported hardware 2019-02-27 16:00:21 +01:00
hpilo.h
ibmvmc.c
ibmvmc.h
ics932s401.c
ioc4.c drivers: Remove explicit invocations of mmiowb() 2019-04-08 12:01:02 +01:00
isl29003.c
isl29020.c
Kconfig Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2019-05-19 11:11:20 -07:00
kgdbts.c Drivers: misc: fix out-of-bounds access in function param_set_kgdbts_var 2019-04-25 22:23:06 +02:00
lattice-ecp3-config.c
Makefile soc: add aspeed folder and misc drivers 2019-04-29 09:36:34 -07:00
pch_phub.c PCI: Move Rohm Vendor ID to generic list 2019-02-01 17:24:52 -06:00
pci_endpoint_test.c misc: pci_endpoint_test: Fix test_reg_bar to be updated in pci_endpoint_test 2019-05-01 15:50:13 +01:00
phantom.c
pti.c
pvpanic.c
qcom-coincell.c
spear13xx_pcie_gadget.c
sram-exec.c
sram.c
sram.h
tifm_7xx1.c drivers: Remove explicit invocations of mmiowb() 2019-04-08 12:01:02 +01:00
tifm_core.c
tsl2550.c
vexpress-syscfg.c
vmw_balloon.c Char/Misc driver patches for 5.1-rc1 2019-03-06 14:18:59 -08:00