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

[XFRM]: Use kmemdup where appropriate

Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@mandriva.com>
parent 2710b57f
...@@ -244,11 +244,10 @@ static int attach_one_algo(struct xfrm_algo **algpp, u8 *props, ...@@ -244,11 +244,10 @@ static int attach_one_algo(struct xfrm_algo **algpp, u8 *props,
*props = algo->desc.sadb_alg_id; *props = algo->desc.sadb_alg_id;
len = sizeof(*ualg) + (ualg->alg_key_len + 7U) / 8; len = sizeof(*ualg) + (ualg->alg_key_len + 7U) / 8;
p = kmalloc(len, GFP_KERNEL); p = kmemdup(ualg, len, GFP_KERNEL);
if (!p) if (!p)
return -ENOMEM; return -ENOMEM;
memcpy(p, ualg, len);
strcpy(p->alg_name, algo->name); strcpy(p->alg_name, algo->name);
*algpp = p; *algpp = p;
return 0; return 0;
...@@ -263,11 +262,10 @@ static int attach_encap_tmpl(struct xfrm_encap_tmpl **encapp, struct rtattr *u_a ...@@ -263,11 +262,10 @@ static int attach_encap_tmpl(struct xfrm_encap_tmpl **encapp, struct rtattr *u_a
return 0; return 0;
uencap = RTA_DATA(rta); uencap = RTA_DATA(rta);
p = kmalloc(sizeof(*p), GFP_KERNEL); p = kmemdup(uencap, sizeof(*p), GFP_KERNEL);
if (!p) if (!p)
return -ENOMEM; return -ENOMEM;
memcpy(p, uencap, sizeof(*p));
*encapp = p; *encapp = p;
return 0; return 0;
} }
...@@ -305,11 +303,10 @@ static int attach_one_addr(xfrm_address_t **addrpp, struct rtattr *u_arg) ...@@ -305,11 +303,10 @@ static int attach_one_addr(xfrm_address_t **addrpp, struct rtattr *u_arg)
return 0; return 0;
uaddrp = RTA_DATA(rta); uaddrp = RTA_DATA(rta);
p = kmalloc(sizeof(*p), GFP_KERNEL); p = kmemdup(uaddrp, sizeof(*p), GFP_KERNEL);
if (!p) if (!p)
return -ENOMEM; return -ENOMEM;
memcpy(p, uaddrp, sizeof(*p));
*addrpp = p; *addrpp = p;
return 0; return 0;
} }
......
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