aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDuan Jiong <duanj.fnst@cn.fujitsu.com>2013-09-26 15:52:13 -0400
committerPaul Moore <pmoore@redhat.com>2013-09-26 15:52:13 -0400
commit7d1db4b242134bb4c7170f4c15491980ac064ac3 (patch)
tree3d9734133276abc1a15e838210cb2e39806e8df3
parent7a362838f9ed1d6806a2b28f68699826423a7e03 (diff)
selinux: Use kmemdup instead of kmalloc + memcpy
Signed-off-by: Duan Jiong <duanj.fnst@cn.fujitsu.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
-rw-r--r--security/selinux/xfrm.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/security/selinux/xfrm.c b/security/selinux/xfrm.c
index 425b9f91d755..a91d205ec0c6 100644
--- a/security/selinux/xfrm.c
+++ b/security/selinux/xfrm.c
@@ -268,10 +268,10 @@ int selinux_xfrm_policy_clone(struct xfrm_sec_ctx *old_ctx,
268 if (!old_ctx) 268 if (!old_ctx)
269 return 0; 269 return 0;
270 270
271 new_ctx = kmalloc(sizeof(*old_ctx) + old_ctx->ctx_len, GFP_ATOMIC); 271 new_ctx = kmemdup(old_ctx, sizeof(*old_ctx) + old_ctx->ctx_len,
272 GFP_ATOMIC);
272 if (!new_ctx) 273 if (!new_ctx)
273 return -ENOMEM; 274 return -ENOMEM;
274 memcpy(new_ctx, old_ctx, sizeof(*old_ctx) + old_ctx->ctx_len);
275 atomic_inc(&selinux_xfrm_refcount); 275 atomic_inc(&selinux_xfrm_refcount);
276 *new_ctxp = new_ctx; 276 *new_ctxp = new_ctx;
277 277