From: Serge E. Hallyn Date: Mon, 15 May 2006 16:43:48 +0000 (-0700) Subject: [PATCH] selinux: check for failed kmalloc in security_sid_to_context() X-Git-Tag: v2.6.17-rc5~157 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0cccca06f9870eb6daa89357b8a99ad041865553;p=platform%2Fkernel%2Flinux-3.10.git [PATCH] selinux: check for failed kmalloc in security_sid_to_context() Check for NULL kmalloc return value before writing to it. Signed-off-by: Serge E. Hallyn Acked-by: James Morris Cc: Stephen Smalley Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c index 7177e98..c284dbb 100644 --- a/security/selinux/ss/services.c +++ b/security/selinux/ss/services.c @@ -594,6 +594,10 @@ int security_sid_to_context(u32 sid, char **scontext, u32 *scontext_len) *scontext_len = strlen(initial_sid_to_string[sid]) + 1; scontextp = kmalloc(*scontext_len,GFP_ATOMIC); + if (!scontextp) { + rc = -ENOMEM; + goto out; + } strcpy(scontextp, initial_sid_to_string[sid]); *scontext = scontextp; goto out;