diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2017-02-14 19:23:32 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-02-17 17:03:06 +0100 |
commit | 6f7aa56bae6ff38727d5c8bf6ee7d4202b4e3865 (patch) | |
tree | 14f800474cdfab3fa80eedb0462d84a52e82b08c /drivers/ptp | |
parent | ptp: do not explicitly set drvdata in ptp_clock_register() (diff) | |
download | linux-6f7aa56bae6ff38727d5c8bf6ee7d4202b4e3865.tar.xz linux-6f7aa56bae6ff38727d5c8bf6ee7d4202b4e3865.zip |
ptp: use kcalloc when allocating arrays
kcalloc is more semantically correct when allocating arrays of objects, and
overflow-safe.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/ptp')
-rw-r--r-- | drivers/ptp/ptp_sysfs.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/ptp/ptp_sysfs.c b/drivers/ptp/ptp_sysfs.c index 53d43954a974..27cd46ab5e32 100644 --- a/drivers/ptp/ptp_sysfs.c +++ b/drivers/ptp/ptp_sysfs.c @@ -269,13 +269,12 @@ static int ptp_populate_pins(struct ptp_clock *ptp) struct ptp_clock_info *info = ptp->info; int err = -ENOMEM, i, n_pins = info->n_pins; - ptp->pin_dev_attr = kzalloc(n_pins * sizeof(*ptp->pin_dev_attr), + ptp->pin_dev_attr = kcalloc(n_pins, sizeof(*ptp->pin_dev_attr), GFP_KERNEL); if (!ptp->pin_dev_attr) goto no_dev_attr; - ptp->pin_attr = kzalloc((1 + n_pins) * sizeof(struct attribute *), - GFP_KERNEL); + ptp->pin_attr = kcalloc(1 + n_pins, sizeof(*ptp->pin_attr), GFP_KERNEL); if (!ptp->pin_attr) goto no_pin_attr; |