diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2019-07-21 17:01:35 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-09-04 12:43:44 +0200 |
commit | df60a8af8420cb440a2456e7b3ec02446f1e2e74 (patch) | |
tree | fff94c6daad8167d58f96a2f99d749942d437aae /drivers/tty/serial/8250/8250_exar.c | |
parent | tty: nozomi: Use dev_get_drvdata (diff) | |
download | linux-df60a8af8420cb440a2456e7b3ec02446f1e2e74.tar.xz linux-df60a8af8420cb440a2456e7b3ec02446f1e2e74.zip |
serial: 8250_exar: Use struct_size() helper
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.
Make use of the struct_size() helper instead of an open-coded version
in order to avoid any potential type mistakes.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20190721150135.82065-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial/8250/8250_exar.c')
-rw-r--r-- | drivers/tty/serial/8250/8250_exar.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c index 03b347afd46c..8d60e5481af0 100644 --- a/drivers/tty/serial/8250/8250_exar.c +++ b/drivers/tty/serial/8250/8250_exar.c @@ -478,9 +478,7 @@ exar_pci_probe(struct pci_dev *pcidev, const struct pci_device_id *ent) nr_ports = board->num_ports ? board->num_ports : pcidev->device & 0x0f; - priv = devm_kzalloc(&pcidev->dev, sizeof(*priv) + - sizeof(unsigned int) * nr_ports, - GFP_KERNEL); + priv = devm_kzalloc(&pcidev->dev, struct_size(priv, line, nr_ports), GFP_KERNEL); if (!priv) return -ENOMEM; |