Skip to contentSkip to conversation

staging: wlags49_h2: Replace kmalloc+memset by kzalloc and add error handling.

PATCH New santosh nayak 1 participant 1 message Mar 23, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 staging: wlags49_h2: Replace kmalloc+memset by kzalloc and add error handling.

From: Santosh Nayak <[email protected]>

Replace kmalloc+memset pair by kzalloc() in 'wl_wds_device_alloc()'. Add error handling to avoid null derefernce.

---
 drivers/staging/wlags49_h2/wl_netdev.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
drivers/staging/wlags49_h2/wl_netdev.c +5 -2
index 9c16f54..b41b572 100644
@@ -1511,8 +1511,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 );
 
Signature · 1 line
1.7.4.4