Re: [PATCH] hv_netvsc: Add check for kvmalloc_array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux