diff options
-rw-r--r-- | net/xfrm/xfrm_user.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c index 6ddb49367c13..6c4d2f49d9e5 100644 --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c | |||
@@ -244,11 +244,10 @@ static int attach_one_algo(struct xfrm_algo **algpp, u8 *props, | |||
244 | *props = algo->desc.sadb_alg_id; | 244 | *props = algo->desc.sadb_alg_id; |
245 | 245 | ||
246 | len = sizeof(*ualg) + (ualg->alg_key_len + 7U) / 8; | 246 | len = sizeof(*ualg) + (ualg->alg_key_len + 7U) / 8; |
247 | p = kmalloc(len, GFP_KERNEL); | 247 | p = kmemdup(ualg, len, GFP_KERNEL); |
248 | if (!p) | 248 | if (!p) |
249 | return -ENOMEM; | 249 | return -ENOMEM; |
250 | 250 | ||
251 | memcpy(p, ualg, len); | ||
252 | strcpy(p->alg_name, algo->name); | 251 | strcpy(p->alg_name, algo->name); |
253 | *algpp = p; | 252 | *algpp = p; |
254 | return 0; | 253 | return 0; |
@@ -263,11 +262,10 @@ static int attach_encap_tmpl(struct xfrm_encap_tmpl **encapp, struct rtattr *u_a | |||
263 | return 0; | 262 | return 0; |
264 | 263 | ||
265 | uencap = RTA_DATA(rta); | 264 | uencap = RTA_DATA(rta); |
266 | p = kmalloc(sizeof(*p), GFP_KERNEL); | 265 | p = kmemdup(uencap, sizeof(*p), GFP_KERNEL); |
267 | if (!p) | 266 | if (!p) |
268 | return -ENOMEM; | 267 | return -ENOMEM; |
269 | 268 | ||
270 | memcpy(p, uencap, sizeof(*p)); | ||
271 | *encapp = p; | 269 | *encapp = p; |
272 | return 0; | 270 | return 0; |
273 | } | 271 | } |
@@ -305,11 +303,10 @@ static int attach_one_addr(xfrm_address_t **addrpp, struct rtattr *u_arg) | |||
305 | return 0; | 303 | return 0; |
306 | 304 | ||
307 | uaddrp = RTA_DATA(rta); | 305 | uaddrp = RTA_DATA(rta); |
308 | p = kmalloc(sizeof(*p), GFP_KERNEL); | 306 | p = kmemdup(uaddrp, sizeof(*p), GFP_KERNEL); |
309 | if (!p) | 307 | if (!p) |
310 | return -ENOMEM; | 308 | return -ENOMEM; |
311 | 309 | ||
312 | memcpy(p, uaddrp, sizeof(*p)); | ||
313 | *addrpp = p; | 310 | *addrpp = p; |
314 | return 0; | 311 | return 0; |
315 | } | 312 | } |