Search Linux Wireless

Re: [PATCH] staging/wilc1000: fixes kzalloc call

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

 



On Fri, 2016-05-27 at 13:51 -0400, Lidza Louina wrote:
> The wl pointer was initialized as a pointer to a struct wilc and
> assigned to a piece of memory the size of the pointer. It should be the
> size of struct wilc.

This isn't necessary.

The code in question is:

	struct wilc *wl;

	sema_init(&close_exit_sync, 0);

	wl = kzalloc(sizeof(*wl), GFP_KERNEL);
	if (!wl)
		return -ENOMEM;

	*wilc = wl;

so this isn't any real change and the generally desired form for
allocations from CodingStyle (Chapter 14: Allocating Memory) is:

The preferred form for passing a size of a struct is the following:	p = kmalloc(sizeof(*p), ...);

> diff --git a/drivers/staging/wilc1000/linux_wlan.c
[]
> @@ -1260,7 +1260,7 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type,
>  
>  	sema_init(&close_exit_sync, 0);
>  
> -	wl = kzalloc(sizeof(*wl), GFP_KERNEL);
> +	wl = kzalloc(sizeof(struct wilc), GFP_KERNEL);
>  	if (!wl)
>  		return -ENOMEM;
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux