aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@mandriva.com>2006-11-17 09:21:43 -0500
committerDavid S. Miller <davem@sunset.davemloft.net>2006-12-03 00:23:59 -0500
commiteed73417d501c2c7bdef1bc8a1f7a1548a635b09 (patch)
tree61fb259d247169bbe4194fff5d6461908fcead1b /net/dccp
parentaf879cc704372ef762584e916129d19ffb39e844 (diff)
[DCCP]: Use kmemdup
Code diff stats: [acme@newtoy net-2.6.20]$ codiff /tmp/dccp.ko.before /tmp/dccp.ko.after /pub/scm/linux/kernel/git/acme/net-2.6.20/net/dccp/feat.c: __dccp_feat_init | -16 dccp_feat_change_recv | -55 dccp_feat_clone | -56 3 functions changed, 127 bytes removed [acme@newtoy net-2.6.20]$ Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
Diffstat (limited to 'net/dccp')
-rw-r--r--net/dccp/feat.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/net/dccp/feat.c b/net/dccp/feat.c
index 12cde2f2f13b..e808c418c992 100644
--- a/net/dccp/feat.c
+++ b/net/dccp/feat.c
@@ -286,12 +286,11 @@ static int dccp_feat_nn(struct sock *sk, u8 type, u8 feature, u8 *val, u8 len)
286 if (opt == NULL) 286 if (opt == NULL)
287 return -ENOMEM; 287 return -ENOMEM;
288 288
289 copy = kmalloc(len, GFP_ATOMIC); 289 copy = kmemdup(val, len, GFP_ATOMIC);
290 if (copy == NULL) { 290 if (copy == NULL) {
291 kfree(opt); 291 kfree(opt);
292 return -ENOMEM; 292 return -ENOMEM;
293 } 293 }
294 memcpy(copy, val, len);
295 294
296 opt->dccpop_type = DCCPO_CONFIRM_R; /* NN can only confirm R */ 295 opt->dccpop_type = DCCPO_CONFIRM_R; /* NN can only confirm R */
297 opt->dccpop_feat = feature; 296 opt->dccpop_feat = feature;
@@ -521,20 +520,18 @@ int dccp_feat_clone(struct sock *oldsk, struct sock *newsk)
521 list_for_each_entry(opt, &olddmsk->dccpms_pending, dccpop_node) { 520 list_for_each_entry(opt, &olddmsk->dccpms_pending, dccpop_node) {
522 struct dccp_opt_pend *newopt; 521 struct dccp_opt_pend *newopt;
523 /* copy the value of the option */ 522 /* copy the value of the option */
524 u8 *val = kmalloc(opt->dccpop_len, GFP_ATOMIC); 523 u8 *val = kmemdup(opt->dccpop_val, opt->dccpop_len, GFP_ATOMIC);
525 524
526 if (val == NULL) 525 if (val == NULL)
527 goto out_clean; 526 goto out_clean;
528 memcpy(val, opt->dccpop_val, opt->dccpop_len);
529 527
530 newopt = kmalloc(sizeof(*newopt), GFP_ATOMIC); 528 newopt = kmemdup(opt, sizeof(*newopt), GFP_ATOMIC);
531 if (newopt == NULL) { 529 if (newopt == NULL) {
532 kfree(val); 530 kfree(val);
533 goto out_clean; 531 goto out_clean;
534 } 532 }
535 533
536 /* insert the option */ 534 /* insert the option */
537 memcpy(newopt, opt, sizeof(*newopt));
538 newopt->dccpop_val = val; 535 newopt->dccpop_val = val;
539 list_add_tail(&newopt->dccpop_node, &newdmsk->dccpms_pending); 536 list_add_tail(&newopt->dccpop_node, &newdmsk->dccpms_pending);
540 537
@@ -565,10 +562,9 @@ static int __dccp_feat_init(struct dccp_minisock *dmsk, u8 type, u8 feat,
565 u8 *val, u8 len) 562 u8 *val, u8 len)
566{ 563{
567 int rc = -ENOMEM; 564 int rc = -ENOMEM;
568 u8 *copy = kmalloc(len, GFP_KERNEL); 565 u8 *copy = kmemdup(val, len, GFP_KERNEL);
569 566
570 if (copy != NULL) { 567 if (copy != NULL) {
571 memcpy(copy, val, len);
572 rc = dccp_feat_change(dmsk, type, feat, copy, len, GFP_KERNEL); 568 rc = dccp_feat_change(dmsk, type, feat, copy, len, GFP_KERNEL);
573 if (rc) 569 if (rc)
574 kfree(copy); 570 kfree(copy);