[ATM]: Use kmemdup & kzalloc where applicable
authorArnaldo Carvalho de Melo <acme@mandriva.com>
Tue, 21 Nov 2006 03:14:33 +0000 (01:14 -0200)
committerDavid S. Miller <davem@sunset.davemloft.net>
Sun, 3 Dec 2006 05:30:13 +0000 (21:30 -0800)
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
net/atm/lec.c
net/atm/mpc.c
net/atm/mpoa_caches.c

index 9f5f931743bd93f6b19b3c0b179531a9e1b7ac8c..5946ec63724f3634abc4b9cd819b3e6d6a9ac6f4 100644 (file)
@@ -1321,11 +1321,10 @@ static int lane2_resolve(struct net_device *dev, u8 *dst_mac, int force,
                if (table == NULL)
                        return -1;
 
-               *tlvs = kmalloc(table->sizeoftlvs, GFP_ATOMIC);
+               *tlvs = kmemdup(table->tlvs, table->sizeoftlvs, GFP_ATOMIC);
                if (*tlvs == NULL)
                        return -1;
 
-               memcpy(*tlvs, table->tlvs, table->sizeoftlvs);
                *sizeoftlvs = table->sizeoftlvs;
 
                return 0;
@@ -1364,11 +1363,10 @@ static int lane2_associate_req(struct net_device *dev, u8 *lan_dst,
 
        kfree(priv->tlvs);      /* NULL if there was no previous association */
 
-       priv->tlvs = kmalloc(sizeoftlvs, GFP_KERNEL);
+       priv->tlvs = kmemdup(tlvs, sizeoftlvs, GFP_KERNEL);
        if (priv->tlvs == NULL)
                return (0);
        priv->sizeoftlvs = sizeoftlvs;
-       memcpy(priv->tlvs, tlvs, sizeoftlvs);
 
        skb = alloc_skb(sizeoftlvs, GFP_ATOMIC);
        if (skb == NULL)
@@ -1409,12 +1407,10 @@ static void lane2_associate_ind(struct net_device *dev, u8 *mac_addr,
 
        kfree(entry->tlvs);
 
-       entry->tlvs = kmalloc(sizeoftlvs, GFP_KERNEL);
+       entry->tlvs = kmemdup(tlvs, sizeoftlvs, GFP_KERNEL);
        if (entry->tlvs == NULL)
                return;
-
        entry->sizeoftlvs = sizeoftlvs;
-       memcpy(entry->tlvs, tlvs, sizeoftlvs);
 #endif
 #if 0
        printk("lec.c: lane2_associate_ind()\n");
index f15f5d84786008a11259cb60bc7f24b90615e8f9..c18f73715ef9799acdc6177f3d2470eb4f10f196 100644 (file)
@@ -1322,13 +1322,12 @@ static void set_mps_mac_addr_rcvd(struct k_message *msg, struct mpoa_client *cli
        if(client->number_of_mps_macs)
                kfree(client->mps_macs);
        client->number_of_mps_macs = 0;
-       client->mps_macs = kmalloc(ETH_ALEN,GFP_KERNEL);
+       client->mps_macs = kmemdup(msg->MPS_ctrl, ETH_ALEN, GFP_KERNEL);
        if (client->mps_macs == NULL) {
                printk("mpoa: set_mps_mac_addr_rcvd: out of memory\n");
                return;
        }
        client->number_of_mps_macs = 1;
-       memcpy(client->mps_macs, msg->MPS_ctrl, ETH_ALEN);
        
        return;
 }
index f3b99b38c91b2310b4dffb7c7fa3d61502da236d..697a081533b5acf26d49731e53d28f6f8d1e781c 100644 (file)
@@ -87,7 +87,7 @@ static in_cache_entry *in_cache_get_by_vcc(struct atm_vcc *vcc,
 static in_cache_entry *in_cache_add_entry(__be32 dst_ip,
                                          struct mpoa_client *client)
 {
-       in_cache_entry* entry = kmalloc(sizeof(in_cache_entry), GFP_KERNEL);
+       in_cache_entry *entry = kzalloc(sizeof(in_cache_entry), GFP_KERNEL);
 
        if (entry == NULL) {
                printk("mpoa: mpoa_caches.c: new_in_cache_entry: out of memory\n");
@@ -95,7 +95,6 @@ static in_cache_entry *in_cache_add_entry(__be32 dst_ip,
        }
 
        dprintk("mpoa: mpoa_caches.c: adding an ingress entry, ip = %u.%u.%u.%u\n", NIPQUAD(dst_ip));
-       memset(entry,0,sizeof(in_cache_entry));
 
        atomic_set(&entry->use, 1);
        dprintk("mpoa: mpoa_caches.c: new_in_cache_entry: about to lock\n");
@@ -447,7 +446,7 @@ static void eg_cache_remove_entry(eg_cache_entry *entry,
 
 static eg_cache_entry *eg_cache_add_entry(struct k_message *msg, struct mpoa_client *client)
 {
-       eg_cache_entry *entry = kmalloc(sizeof(eg_cache_entry), GFP_KERNEL);
+       eg_cache_entry *entry = kzalloc(sizeof(eg_cache_entry), GFP_KERNEL);
 
        if (entry == NULL) {
                printk("mpoa: mpoa_caches.c: new_eg_cache_entry: out of memory\n");
@@ -455,7 +454,6 @@ static eg_cache_entry *eg_cache_add_entry(struct k_message *msg, struct mpoa_cli
        }
 
        dprintk("mpoa: mpoa_caches.c: adding an egress entry, ip = %u.%u.%u.%u, this should be our IP\n", NIPQUAD(msg->content.eg_info.eg_dst_ip));
-       memset(entry, 0, sizeof(eg_cache_entry));
 
        atomic_set(&entry->use, 1);
        dprintk("mpoa: mpoa_caches.c: new_eg_cache_entry: about to lock\n");