Re: [PATCH] staging: wlags49_h2: Replace kmalloc+memset by kzalloc and add error handling.

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

 



On Fri, Mar 23, 2012 at 03:11:45PM +0530, santosh nayak wrote:
> From: Santosh Nayak <santoshprasadnayak@xxxxxxxxx>
> 
> Replace kmalloc+memset pair by kzalloc() in 'wl_wds_device_alloc()'.
> Add error handling to avoid null derefernce.
> 
> Signed-off-by: Santosh Nayak <santoshprasadnayak@xxxxxxxxx>
> ---
>  drivers/staging/wlags49_h2/wl_netdev.c |    8 ++++++--
>  1 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/wlags49_h2/wl_netdev.c b/drivers/staging/wlags49_h2/wl_netdev.c
> index 9c16f54..426ba04 100644
> --- a/drivers/staging/wlags49_h2/wl_netdev.c
> +++ b/drivers/staging/wlags49_h2/wl_netdev.c
> @@ -1511,8 +1511,12 @@ void wl_wds_device_alloc( struct wl_private *lp )
>      for( count = 0; count < NUM_WDS_PORTS; count++ ) {
>          struct net_device *dev_wds = NULL;
>  
> -        dev_wds = kmalloc( sizeof( struct net_device ), GFP_KERNEL );
> -        memset( dev_wds, 0, sizeof( struct net_device ));
> +	dev_wds = kzalloc(sizeof(struct net_device), GFP_KERNEL);
> +	if (unlikely(!dev_wds)) {

NEVER use unlikely unless you are working on scheduler code, or
something else equally time critical.  So, take this into consideration,
and Dan's comments, and please redo this, I can't take it as-is.

thanks,

greg k-h
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [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