linux_dsm_epyc7002/drivers/usb/dwc2
Gustavo A. R. Silva eeca7606dd usb: dwc2: 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 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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-02-19 14:41:38 +01:00
..
core_intr.c usb: dwc2: Modify dwc2_readl/writel functions prototype 2018-07-30 10:39:16 +03:00
core.c usb: dwc2: Modify dwc2_readl/writel functions prototype 2018-07-30 10:39:16 +03:00
core.h usb: dwc2: gadget: Program GREFCLK register 2018-10-02 10:50:22 +03:00
debug.h usb: dwc2: Fix kernel doc's warnings. 2018-05-21 10:02:13 +03:00
debugfs.c usb: dwc2: Add core parameter for service interval support 2018-10-02 10:49:26 +03:00
gadget.c usb: dwc2: gadget: Add scatter-gather mode 2019-02-07 13:14:51 +02:00
hcd_ddma.c usb: dwc2: Modify dwc2_readl/writel functions prototype 2018-07-30 10:39:16 +03:00
hcd_intr.c usb: changes for v4.19 2018-07-30 10:21:14 +02:00
hcd_queue.c usb: dwc2: host: use hrtimer for NAK retries 2018-12-05 11:13:14 +02:00
hcd.c usb: dwc2: use struct_size() in kzalloc() 2019-02-19 14:41:38 +01:00
hcd.h usb: dwc2: host: use hrtimer for NAK retries 2018-12-05 11:13:14 +02:00
hw.h usb: dwc2: gadget: Accept LPM token when TxFIFO is not empty 2018-11-26 09:06:32 +02:00
Kconfig USB: add missing SPDX lines to Kconfig and Makefiles 2019-01-22 09:08:17 +01:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
params.c usb: dwc2: disable power_down on Amlogic devices 2018-12-10 09:18:19 +02:00
pci.c usb: dwc2: pci: Fix an error code in probe 2018-11-14 11:07:12 +02:00
platform.c usb: dwc2: get optional vbus-supply regulator once 2018-10-02 10:37:01 +03:00