2008-02-05 16:23:25

by Jim Meyering

[permalink] [raw]
Subject: [PATCH] uml: Handle failed malloc.


* arch/um/os-Linux/mem.c (make_tempfile): Don't deref NULL upon failed malloc.

Signed-off-by: Jim Meyering <[email protected]>
---
diff --git a/arch/um/os-Linux/mem.c b/arch/um/os-Linux/mem.c
index 436f8d2..e114d09 100644
--- a/arch/um/os-Linux/mem.c
+++ b/arch/um/os-Linux/mem.c
@@ -172,6 +172,8 @@ int __init make_tempfile(const char *template, char **out_tempname,

which_tmpdir();
tempname = malloc(MAXPATHLEN);
+ if (tempname == NULL)
+ return -1;

find_tempdir();
if (template[0] != '/')