Commit 6f7aa56b authored by Dmitry Torokhov's avatar Dmitry Torokhov Committed by David S. Miller

ptp: use kcalloc when allocating arrays

kcalloc is more semantically correct when allocating arrays of objects, and
overflow-safe.
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 882f312d
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment