Skip to content

Commit

Permalink
[PATCH] selinux: check for failed kmalloc in security_sid_to_context()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Serge E. Hallyn authored and Linus Torvalds committed May 15, 2006
1 parent 9be2f7c commit 0cccca0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions security/selinux/ss/services.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0cccca0

Please sign in to comment.