staging: wlags49_h2: Replace kmalloc+memset by kzalloc and add error handling.
authorSantosh Nayak <santoshprasadnayak@gmail.com>
Fri, 23 Mar 2012 15:44:02 +0000 (21:14 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 10 Apr 2012 16:47:06 +0000 (09:47 -0700)
Replace kmalloc+memset pair by kzalloc() in 'wl_wds_device_alloc()'.
Add error handling to avoid null derefernce.

Signed-off-by: Santosh Nayak <santoshprasadnayak@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/wlags49_h2/wl_netdev.c

index 90820ff1aced92bf14a0ecd4944583cfba024d6a..6a44cb87bdf6b7d52bdf7e2c4b68041e163be2a0 100644 (file)
@@ -1510,8 +1510,11 @@ 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 (!dev_wds) {
+               DBG_LEAVE(DbgInfo);
+               return;
+       }
 
         ether_setup( dev_wds );