[PATCH 14/17] uml: fix big stack user
- From: "Paolo 'Blaisorblade' Giarrusso" <blaisorblade@xxxxxxxx>
- Date: Fri, 07 Apr 2006 16:31:22 +0200
From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@xxxxxxxx>
Switch this proc from storing 4k of data (a whole path) on the stack to keeping
it on the heap.
Maybe it's not called in process context but only in early boot context (where
in UML you have a normal process stack on the host) but just to be safe, fix it.
While at it some little readability simplifications.
Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@xxxxxxxx>
---
arch/um/os-Linux/mem.c | 23 +++++++++++++----------
1 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/arch/um/os-Linux/mem.c b/arch/um/os-Linux/mem.c
index 6ab372d..71bb90a 100644
--- a/arch/um/os-Linux/mem.c
+++ b/arch/um/os-Linux/mem.c
@@ -53,33 +53,36 @@ static void __init find_tempdir(void)
*/
int make_tempfile(const char *template, char **out_tempname, int do_unlink)
{
- char tempname[MAXPATHLEN];
+ char *tempname;
int fd;
+ tempname = malloc(MAXPATHLEN);
+
find_tempdir();
- if (*template != '/')
+ if (template[0] != '/')
strcpy(tempname, tempdir);
else
- *tempname = 0;
+ tempname[0] = '\0';
strcat(tempname, template);
fd = mkstemp(tempname);
if(fd < 0){
fprintf(stderr, "open - cannot create %s: %s\n", tempname,
strerror(errno));
- return -1;
+ goto out;
}
if(do_unlink && (unlink(tempname) < 0)){
perror("unlink");
- return -1;
+ goto out;
}
if(out_tempname){
- *out_tempname = strdup(tempname);
- if(*out_tempname == NULL){
- perror("strdup");
- return -1;
- }
+ *out_tempname = tempname;
+ } else {
+ free(tempname);
}
return(fd);
+out:
+ free(tempname);
+ return -1;
}
#define TEMPNAME_TEMPLATE "vm_file-XXXXXX"
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
- References:
- [PATCH 00/17] Uml little fixups for new and existing code [for 2.6.17]
- From: Paolo 'Blaisorblade' Giarrusso
- [PATCH 00/17] Uml little fixups for new and existing code [for 2.6.17]
- Prev by Date: Re: [patch] ipv4: initialize arp_tbl rw lock
- Next by Date: [PATCH 16/17] uml: fix parallel make early failure on clean tree
- Previous by thread: [PATCH 11/17] uml: move outside spinlock call not needing it
- Next by thread: [PATCH 16/17] uml: fix parallel make early failure on clean tree
- Index(es):
Relevant Pages
|