Commit eed73417 authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo Committed by David S. Miller

[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: default avatarArnaldo Carvalho de Melo <acme@mandriva.com>
parent af879cc7
...@@ -286,12 +286,11 @@ static int dccp_feat_nn(struct sock *sk, u8 type, u8 feature, u8 *val, u8 len) ...@@ -286,12 +286,11 @@ static int dccp_feat_nn(struct sock *sk, u8 type, u8 feature, u8 *val, u8 len)
if (opt == NULL) if (opt == NULL)
return -ENOMEM; return -ENOMEM;
copy = kmalloc(len, GFP_ATOMIC); copy = kmemdup(val, len, GFP_ATOMIC);
if (copy == NULL) { if (copy == NULL) {
kfree(opt); kfree(opt);
return -ENOMEM; return -ENOMEM;
} }
memcpy(copy, val, len);
opt->dccpop_type = DCCPO_CONFIRM_R; /* NN can only confirm R */ opt->dccpop_type = DCCPO_CONFIRM_R; /* NN can only confirm R */
opt->dccpop_feat = feature; opt->dccpop_feat = feature;
...@@ -521,20 +520,18 @@ int dccp_feat_clone(struct sock *oldsk, struct sock *newsk) ...@@ -521,20 +520,18 @@ int dccp_feat_clone(struct sock *oldsk, struct sock *newsk)
list_for_each_entry(opt, &olddmsk->dccpms_pending, dccpop_node) { list_for_each_entry(opt, &olddmsk->dccpms_pending, dccpop_node) {
struct dccp_opt_pend *newopt; struct dccp_opt_pend *newopt;
/* copy the value of the option */ /* copy the value of the option */
u8 *val = kmalloc(opt->dccpop_len, GFP_ATOMIC); u8 *val = kmemdup(opt->dccpop_val, opt->dccpop_len, GFP_ATOMIC);
if (val == NULL) if (val == NULL)
goto out_clean; goto out_clean;
memcpy(val, opt->dccpop_val, opt->dccpop_len);
newopt = kmalloc(sizeof(*newopt), GFP_ATOMIC); newopt = kmemdup(opt, sizeof(*newopt), GFP_ATOMIC);
if (newopt == NULL) { if (newopt == NULL) {
kfree(val); kfree(val);
goto out_clean; goto out_clean;
} }
/* insert the option */ /* insert the option */
memcpy(newopt, opt, sizeof(*newopt));
newopt->dccpop_val = val; newopt->dccpop_val = val;
list_add_tail(&newopt->dccpop_node, &newdmsk->dccpms_pending); list_add_tail(&newopt->dccpop_node, &newdmsk->dccpms_pending);
...@@ -565,10 +562,9 @@ static int __dccp_feat_init(struct dccp_minisock *dmsk, u8 type, u8 feat, ...@@ -565,10 +562,9 @@ static int __dccp_feat_init(struct dccp_minisock *dmsk, u8 type, u8 feat,
u8 *val, u8 len) u8 *val, u8 len)
{ {
int rc = -ENOMEM; int rc = -ENOMEM;
u8 *copy = kmalloc(len, GFP_KERNEL); u8 *copy = kmemdup(val, len, GFP_KERNEL);
if (copy != NULL) { if (copy != NULL) {
memcpy(copy, val, len);
rc = dccp_feat_change(dmsk, type, feat, copy, len, GFP_KERNEL); rc = dccp_feat_change(dmsk, type, feat, copy, len, GFP_KERNEL);
if (rc) if (rc)
kfree(copy); kfree(copy);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment