From: Duan Jiong Date: Thu, 26 Sep 2013 19:52:13 +0000 (-0400) Subject: selinux: Use kmemdup instead of kmalloc + memcpy X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=7d1db4b242134bb4c7170f4c15491980ac064ac3;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git selinux: Use kmemdup instead of kmalloc + memcpy Signed-off-by: Duan Jiong Signed-off-by: Paul Moore --- 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, if (!old_ctx) return 0; - new_ctx = kmalloc(sizeof(*old_ctx) + old_ctx->ctx_len, GFP_ATOMIC); + new_ctx = kmemdup(old_ctx, sizeof(*old_ctx) + old_ctx->ctx_len, + GFP_ATOMIC); if (!new_ctx) return -ENOMEM; - memcpy(new_ctx, old_ctx, sizeof(*old_ctx) + old_ctx->ctx_len); atomic_inc(&selinux_xfrm_refcount); *new_ctxp = new_ctx;