linux_dsm_epyc7002/drivers
Gustavo A. R. Silva 78844068a7 mlxsw: spectrum: acl: Use struct_size() in 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 = kzalloc(size, GFP_KERNEL)

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

instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL)

Notice that, in this case, variable alloc_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>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-02-25 14:18:02 -08:00
..
accessibility
acpi
amba
android
ata
atm
auxdisplay
base PM-runtime: Fix deadlock when canceling hrtimer 2019-02-21 10:29:00 +01:00
bcma
block
bluetooth
bus
cdrom
char
clk clk: at91: fix masterck name 2019-02-20 11:40:21 -08:00
clocksource
connector
cpufreq cpufreq: scmi: Fix use-after-free in scmi_cpufreq_exit() 2019-02-19 11:17:37 +01:00
cpuidle
crypto
dax
dca
devfreq
dio
dma
dma-buf
edac
eisa
extcon
firewire
firmware
fmc
fpga
fsi
gnss
gpio
gpu Merge branch 'drm-fixes-5.0' of git://people.freedesktop.org/~agd5f/linux into drm-fixes 2019-02-22 09:35:25 +10:00
hid
hsi
hv
hwmon
hwspinlock
hwtracing
i2c
i3c
ide
idle
iio
infiniband Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2019-02-24 12:06:19 -08:00
input
iommu
ipack
irqchip
isdn isdn_common: Mark expected switch fall-throughs 2019-02-22 11:48:20 -08:00
leds
lightnvm
macintosh
mailbox
mcb
md
media
memory
memstick
message
mfd
misc
mmc
mtd
mux
net mlxsw: spectrum: acl: Use struct_size() in kzalloc() 2019-02-25 14:18:02 -08:00
nfc
ntb
nubus
nvdimm
nvme
nvmem
of
opp
oprofile
parisc
parport
pci
pcmcia
perf
phy
pinctrl
platform
pnp
power
powercap
pps
ps3
ptp ptp_qoriq: don't pass a large struct by value but instead pass it by reference 2019-02-19 14:15:40 -08:00
pwm
rapidio
ras
regulator
remoteproc
reset
rpmsg
rtc
s390
sbus
scsi SCSI fixes on 20190222 2019-02-23 09:48:01 -08:00
sfi
sh
siox
slimbus
sn
soc
soundwire
spi
spmi
ssb
staging net: Get rid of switchdev_port_attr_get() 2019-02-21 14:55:14 -08:00
target
tc
tee
thermal
thunderbolt
tty
uio
usb Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next 2019-02-24 22:27:19 -08:00
uwb
vfio
vhost vhost: correctly check the return value of translate_desc() in log_used() 2019-02-19 13:14:45 -08:00
video
virt
virtio
visorbus
vlynq
vme
w1
watchdog
xen
zorro
Kconfig
Makefile