mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] selinux: check for failed kmalloc in security_sid_to_context
@ 2006-04-27  2:07 Serge E. Hallyn
  2006-04-27  3:25 ` James Morris
  0 siblings, 1 reply; 4+ messages in thread
From: Serge E. Hallyn @ 2006-04-27  2:07 UTC (permalink / raw)
  To: lkml, Stephen Smalley, James Morris

Check for NULL kmalloc return value before writing to it.

Signed-off-by: Serge E. Hallyn <serue@us.ibm.com>

---

 security/selinux/ss/services.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

3d9cf05c7fa2578f87648dd0862e70cf7959ad7a
diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c
index 6149248..20b1065 100644
--- a/security/selinux/ss/services.c
+++ b/security/selinux/ss/services.c
@@ -593,6 +593,10 @@ int security_sid_to_context(u32 sid, cha
 
 			*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;
-- 
1.3.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-05-08 18:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-27  2:07 [PATCH] selinux: check for failed kmalloc in security_sid_to_context Serge E. Hallyn
2006-04-27  3:25 ` James Morris
2006-05-08 17:46   ` Andrew Morton
2006-05-08 18:21     ` Stephen Smalley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®