aboutsummaryrefslogtreecommitdiff
path: root/security
diff options
context:
space:
mode:
authorGeyslan G. Bem <geyslan@gmail.com>2013-12-04 16:10:24 -0500
committerPaul Moore <pmoore@redhat.com>2013-12-04 16:10:24 -0500
commit0af901643fe3f1f8d44e41115d36609ee4bda2bf (patch)
treeba01c6063e7f342725040b661136174a5ae52276 /security
parentdd0a11815a339d6deeea8357574f8126a8404c92 (diff)
selinux: fix possible memory leak
Free 'ctx_str' when necessary. Signed-off-by: Geyslan G. Bem <geyslan@gmail.com> Signed-off-by: Paul Moore <pmoore@redhat.com>
Diffstat (limited to 'security')
-rw-r--r--security/selinux/xfrm.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/security/selinux/xfrm.c b/security/selinux/xfrm.c
index a91d205ec0c..cf79a4564e3 100644
--- a/security/selinux/xfrm.c
+++ b/security/selinux/xfrm.c
@@ -327,19 +327,22 @@ int selinux_xfrm_state_alloc_acquire(struct xfrm_state *x,
return rc;
ctx = kmalloc(sizeof(*ctx) + str_len, GFP_ATOMIC);
- if (!ctx)
- return -ENOMEM;
+ if (!ctx) {
+ rc = -ENOMEM;
+ goto out;
+ }
ctx->ctx_doi = XFRM_SC_DOI_LSM;
ctx->ctx_alg = XFRM_SC_ALG_SELINUX;
ctx->ctx_sid = secid;
ctx->ctx_len = str_len;
memcpy(ctx->ctx_str, ctx_str, str_len);
- kfree(ctx_str);
x->security = ctx;
atomic_inc(&selinux_xfrm_refcount);
- return 0;
+out:
+ kfree(ctx_str);
+ return rc;
}
/*