bonding: Replace kmalloc() + memset() pairs with the appropriate kzalloc() calls
PATCH 1/1 bonding: Replace kmalloc() + memset() pairs with the appropriate kzalloc() calls
This patch replace kmalloc() + memset() pairs with the appropriate kzalloc() calls.
--
diff -urNp old/drivers/net/bonding/bond_alb.c new/drivers/net/bonding/bond_alb.c
--- old/drivers/net/bonding/bond_alb.c 2006-11-30 05:57:37.000000000
+0800
+++ new/drivers/net/bonding/bond_alb.c 2007-01-09 13:13:16.000000000
+0800
@@ -184,7 +184,7 @@ static int tlb_initialize(struct bonding
spin_lock_init(&(bond_info->tx_hashtbl_lock));
- new_hashtbl = kmalloc(size, GFP_KERNEL);
+ new_hashtbl = kzalloc(size, GFP_KERNEL);
if (!new_hashtbl) {
printk(KERN_ERR DRV_NAME
": %s: Error: Failed to allocate TLB hash table\n",
@@ -195,8 +195,6 @@ static int tlb_initialize(struct bonding
bond_info->tx_hashtbl = new_hashtbl;
- memset(bond_info->tx_hashtbl, 0, size);
-
for (i = 0; i < TLB_HASH_TABLE_SIZE; i++) {
tlb_init_table_entry(&bond_info->tx_hashtbl[i], 1);
}
@@ -788,7 +786,7 @@ static int rlb_initialize(struct bonding
spin_lock_init(&(bond_info->rx_hashtbl_lock));
- new_hashtbl = kmalloc(size, GFP_KERNEL);
+ new_hashtbl = kzalloc(size, GFP_KERNEL);
if (!new_hashtbl) {
printk(KERN_ERR DRV_NAME
": %s: Error: Failed to allocate RLB hash table\n",
diff -urNp old/drivers/net/bonding/bond_main.c new/drivers/net/bonding/bond_main.c
--- old/drivers/net/bonding/bond_main.c 2006-11-30 05:57:37.000000000
+0800
+++ new/drivers/net/bonding/bond_main.c 2007-01-09 13:14:20.000000000
+0800
@@ -1336,14 +1336,12 @@ int bond_enslave(struct net_device *bond
goto err_undo_flags;
}
- new_slave = kmalloc(sizeof(struct slave), GFP_KERNEL);
+ new_slave = kzalloc(sizeof(struct slave), GFP_KERNEL);
if (!new_slave) {
res = -ENOMEM;
goto err_undo_flags;
}
- memset(new_slave, 0, sizeof(struct slave));
-
/* save slave's original flags before calling
* netdev_set_master and dev_open
*/
Hi Joe,
Review static int rlb_initialize(struct bonding · line 792
Quoted 9 lines · joe jin
(quoted diff) +1
-1@@ -788,7 +786,7 @@ static int rlb_initialize(struct bonding spin_lock_init(&(bond_info->rx_hashtbl_lock)); - new_hashtbl = kmalloc(size, GFP_KERNEL); + new_hashtbl = kzalloc(size, GFP_KERNEL); if (!new_hashtbl) { printk(KERN_ERR DRV_NAME ": %s: Error: Failed to allocate RLB hash table\n",
You forgot to remove the memset here.
Quoted 7 lines
Hi Joe,
Quoted 4 lines · joe jin
(quoted diff) +0
-0@@ -788,7 +786,7 @@ static int rlb_initialize(struct bonding spin_lock_init(&(bond_info->rx_hashtbl_lock));
Quoted 7 lines
Review static int rlb_initialize(struct bonding · line 792
Quoted 5 lines
(quoted diff) +1
-1- new_hashtbl = kmalloc(size, GFP_KERNEL); + new_hashtbl = kzalloc(size, GFP_KERNEL); if (!new_hashtbl) { printk(KERN_ERR DRV_NAME ": %s: Error: Failed to allocate RLB hash table\n",You forgot to remove the memset here.
Here is not a memset :)