diff options
author | Arnaldo Carvalho de Melo <acme@mandriva.com> | 2006-11-20 22:14:33 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-12-03 00:30:13 -0500 |
commit | 2afe37cdffa96f69c9096e6d4a10a275c9c7d2c9 (patch) | |
tree | b5898081aa18d60bf95595d906de39cc0e617787 /net/atm | |
parent | 66625984ca94552f75836596e0e83f3e5594bd58 (diff) |
[ATM]: Use kmemdup & kzalloc where applicable
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
Diffstat (limited to 'net/atm')
-rw-r--r-- | net/atm/lec.c | 10 | ||||
-rw-r--r-- | net/atm/mpc.c | 3 | ||||
-rw-r--r-- | net/atm/mpoa_caches.c | 6 |
3 files changed, 6 insertions, 13 deletions
diff --git a/net/atm/lec.c b/net/atm/lec.c index 9f5f931743bd..5946ec63724f 100644 --- a/net/atm/lec.c +++ b/net/atm/lec.c | |||
@@ -1321,11 +1321,10 @@ static int lane2_resolve(struct net_device *dev, u8 *dst_mac, int force, | |||
1321 | if (table == NULL) | 1321 | if (table == NULL) |
1322 | return -1; | 1322 | return -1; |
1323 | 1323 | ||
1324 | *tlvs = kmalloc(table->sizeoftlvs, GFP_ATOMIC); | 1324 | *tlvs = kmemdup(table->tlvs, table->sizeoftlvs, GFP_ATOMIC); |
1325 | if (*tlvs == NULL) | 1325 | if (*tlvs == NULL) |
1326 | return -1; | 1326 | return -1; |
1327 | 1327 | ||
1328 | memcpy(*tlvs, table->tlvs, table->sizeoftlvs); | ||
1329 | *sizeoftlvs = table->sizeoftlvs; | 1328 | *sizeoftlvs = table->sizeoftlvs; |
1330 | 1329 | ||
1331 | return 0; | 1330 | return 0; |
@@ -1364,11 +1363,10 @@ static int lane2_associate_req(struct net_device *dev, u8 *lan_dst, | |||
1364 | 1363 | ||
1365 | kfree(priv->tlvs); /* NULL if there was no previous association */ | 1364 | kfree(priv->tlvs); /* NULL if there was no previous association */ |
1366 | 1365 | ||
1367 | priv->tlvs = kmalloc(sizeoftlvs, GFP_KERNEL); | 1366 | priv->tlvs = kmemdup(tlvs, sizeoftlvs, GFP_KERNEL); |
1368 | if (priv->tlvs == NULL) | 1367 | if (priv->tlvs == NULL) |
1369 | return (0); | 1368 | return (0); |
1370 | priv->sizeoftlvs = sizeoftlvs; | 1369 | priv->sizeoftlvs = sizeoftlvs; |
1371 | memcpy(priv->tlvs, tlvs, sizeoftlvs); | ||
1372 | 1370 | ||
1373 | skb = alloc_skb(sizeoftlvs, GFP_ATOMIC); | 1371 | skb = alloc_skb(sizeoftlvs, GFP_ATOMIC); |
1374 | if (skb == NULL) | 1372 | if (skb == NULL) |
@@ -1409,12 +1407,10 @@ static void lane2_associate_ind(struct net_device *dev, u8 *mac_addr, | |||
1409 | 1407 | ||
1410 | kfree(entry->tlvs); | 1408 | kfree(entry->tlvs); |
1411 | 1409 | ||
1412 | entry->tlvs = kmalloc(sizeoftlvs, GFP_KERNEL); | 1410 | entry->tlvs = kmemdup(tlvs, sizeoftlvs, GFP_KERNEL); |
1413 | if (entry->tlvs == NULL) | 1411 | if (entry->tlvs == NULL) |
1414 | return; | 1412 | return; |
1415 | |||
1416 | entry->sizeoftlvs = sizeoftlvs; | 1413 | entry->sizeoftlvs = sizeoftlvs; |
1417 | memcpy(entry->tlvs, tlvs, sizeoftlvs); | ||
1418 | #endif | 1414 | #endif |
1419 | #if 0 | 1415 | #if 0 |
1420 | printk("lec.c: lane2_associate_ind()\n"); | 1416 | printk("lec.c: lane2_associate_ind()\n"); |
diff --git a/net/atm/mpc.c b/net/atm/mpc.c index f15f5d847860..c18f73715ef9 100644 --- a/net/atm/mpc.c +++ b/net/atm/mpc.c | |||
@@ -1322,13 +1322,12 @@ static void set_mps_mac_addr_rcvd(struct k_message *msg, struct mpoa_client *cli | |||
1322 | if(client->number_of_mps_macs) | 1322 | if(client->number_of_mps_macs) |
1323 | kfree(client->mps_macs); | 1323 | kfree(client->mps_macs); |
1324 | client->number_of_mps_macs = 0; | 1324 | client->number_of_mps_macs = 0; |
1325 | client->mps_macs = kmalloc(ETH_ALEN,GFP_KERNEL); | 1325 | client->mps_macs = kmemdup(msg->MPS_ctrl, ETH_ALEN, GFP_KERNEL); |
1326 | if (client->mps_macs == NULL) { | 1326 | if (client->mps_macs == NULL) { |
1327 | printk("mpoa: set_mps_mac_addr_rcvd: out of memory\n"); | 1327 | printk("mpoa: set_mps_mac_addr_rcvd: out of memory\n"); |
1328 | return; | 1328 | return; |
1329 | } | 1329 | } |
1330 | client->number_of_mps_macs = 1; | 1330 | client->number_of_mps_macs = 1; |
1331 | memcpy(client->mps_macs, msg->MPS_ctrl, ETH_ALEN); | ||
1332 | 1331 | ||
1333 | return; | 1332 | return; |
1334 | } | 1333 | } |
diff --git a/net/atm/mpoa_caches.c b/net/atm/mpoa_caches.c index f3b99b38c91b..697a081533b5 100644 --- a/net/atm/mpoa_caches.c +++ b/net/atm/mpoa_caches.c | |||
@@ -87,7 +87,7 @@ static in_cache_entry *in_cache_get_by_vcc(struct atm_vcc *vcc, | |||
87 | static in_cache_entry *in_cache_add_entry(__be32 dst_ip, | 87 | static in_cache_entry *in_cache_add_entry(__be32 dst_ip, |
88 | struct mpoa_client *client) | 88 | struct mpoa_client *client) |
89 | { | 89 | { |
90 | in_cache_entry* entry = kmalloc(sizeof(in_cache_entry), GFP_KERNEL); | 90 | in_cache_entry *entry = kzalloc(sizeof(in_cache_entry), GFP_KERNEL); |
91 | 91 | ||
92 | if (entry == NULL) { | 92 | if (entry == NULL) { |
93 | printk("mpoa: mpoa_caches.c: new_in_cache_entry: out of memory\n"); | 93 | 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, | |||
95 | } | 95 | } |
96 | 96 | ||
97 | dprintk("mpoa: mpoa_caches.c: adding an ingress entry, ip = %u.%u.%u.%u\n", NIPQUAD(dst_ip)); | 97 | dprintk("mpoa: mpoa_caches.c: adding an ingress entry, ip = %u.%u.%u.%u\n", NIPQUAD(dst_ip)); |
98 | memset(entry,0,sizeof(in_cache_entry)); | ||
99 | 98 | ||
100 | atomic_set(&entry->use, 1); | 99 | atomic_set(&entry->use, 1); |
101 | dprintk("mpoa: mpoa_caches.c: new_in_cache_entry: about to lock\n"); | 100 | 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, | |||
447 | 446 | ||
448 | static eg_cache_entry *eg_cache_add_entry(struct k_message *msg, struct mpoa_client *client) | 447 | static eg_cache_entry *eg_cache_add_entry(struct k_message *msg, struct mpoa_client *client) |
449 | { | 448 | { |
450 | eg_cache_entry *entry = kmalloc(sizeof(eg_cache_entry), GFP_KERNEL); | 449 | eg_cache_entry *entry = kzalloc(sizeof(eg_cache_entry), GFP_KERNEL); |
451 | 450 | ||
452 | if (entry == NULL) { | 451 | if (entry == NULL) { |
453 | printk("mpoa: mpoa_caches.c: new_eg_cache_entry: out of memory\n"); | 452 | 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 | |||
455 | } | 454 | } |
456 | 455 | ||
457 | 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)); | 456 | 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)); |
458 | memset(entry, 0, sizeof(eg_cache_entry)); | ||
459 | 457 | ||
460 | atomic_set(&entry->use, 1); | 458 | atomic_set(&entry->use, 1); |
461 | dprintk("mpoa: mpoa_caches.c: new_eg_cache_entry: about to lock\n"); | 459 | dprintk("mpoa: mpoa_caches.c: new_eg_cache_entry: about to lock\n"); |