projects/linux·commit 0cccca06

[PATCH] selinux: check for failed kmalloc in security_sid_to_context()

0cccca06 · Serge E. Hallyn <[email protected]> · 2006-05-15 09:43:48 -07:00

Check for NULL kmalloc return value before writing to it.

Signed-off-by: Serge E. Hallyn <[email protected]>
Acked-by: James Morris <[email protected]>
Cc: Stephen Smalley <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Commit
0cccca06f9870eb6daa89357b8a99ad041865553
Parents
9be2f7c3

Changes

1 files changed · +4 −0

FileStatusAddDelContent
security/selinux/ss/services.cmodified+4−0View file

security/selinux/ss/services.c

View file
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;