Re: [PATCH] hv_netvsc: Add check for kvmalloc_array

From: Jiasheng Jiang
Date: Sun Mar 13 2022 - 21:56:25 EST


On Sat, 12 Mar 2022 01:25:38 +0800
Stephen Hemminger <stephen@xxxxxxxxxxxxxxxxxx> wrote:

>> + if (!pcpu_sum) {
>> + for (j = 0; j < i; j++)
>> + data[j] = 0;
>> + return;
>> + }
>
> I don't think you understood what my comment was.
>
> The zeroing here is not necessary. Just do:
> if (!pcpu_sum)
> return;
>
> The data pointer is to buffer allocated here:
>
> static int ethtool_get_stats(struct net_device *dev, void __user *useraddr)
> {
> ...
> if (n_stats) {
> data = vzalloc(array_size(n_stats, sizeof(u64))); <<<<< is already zeroed.
> if (!data)
> return -ENOMEM;
> ops->get_ethtool_stats(dev, &stats, data);

OK, I will submit a v2 to remove them.

Jiang