Re: [PATCH] staging: r8188eu: use kzalloc instead of kmalloc and memset

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

 



On Wed, Oct 13, 2021 at 03:01:28AM -0400, Wan Jiabing wrote:
> Fix following coccicheck warning:
> ./drivers/staging/r8188eu/os_dep/ioctl_linux.c:422:10-17:
> WARNING: kzalloc should be used for pwep, instead of kmalloc/memset
> 
> Signed-off-by: Wan Jiabing <wanjiabing@xxxxxxxx>
> ---
>  drivers/staging/r8188eu/os_dep/ioctl_linux.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
> index 0201f6fbeb25..51f46696a593 100644
> --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c
> +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
> @@ -419,11 +419,10 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
>  		if (wep_key_len > 0) {
>  			wep_key_len = wep_key_len <= 5 ? 5 : 13;
>  			wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial);
> -			pwep = kmalloc(wep_total_len, GFP_KERNEL);
> +			pwep = kzalloc(wep_total_len, GFP_KERNEL);
>  			if (!pwep)
>  				goto exit;

Not related to your patch, but this is missing an error code as well.
It should be:

	if (!pwep) {
		ret = -ENOMEM;
		goto exit;
	}

regards,
dan carpenter





[Index of Archives]     [Linux Driver Development]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux