[PATCH] selinux: check for failed kmalloc in security_sid_to_context()
authorSerge E. Hallyn <serue@us.ibm.com>
Mon, 15 May 2006 16:43:48 +0000 (09:43 -0700)
committerChris Wright <chrisw@sous-sol.org>
Sat, 20 May 2006 22:00:31 +0000 (15:00 -0700)
Check for NULL kmalloc return value before writing to it.

Signed-off-by: Serge E. Hallyn <serue@us.ibm.com>
Acked-by: James Morris <jmorris@namei.org>
Cc: Stephen Smalley <sds@tycho.nsa.gov>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
security/selinux/ss/services.c

index 8a764928ff4be967d49709121991f4691c0f21e1..6375dd578b39c69d6929d7ef421044757506d5be 100644 (file)
@@ -592,6 +592,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;