diff options
author | Jeff Garzik <jeff@garzik.org> | 2006-04-11 12:51:40 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2006-04-11 12:51:40 -0400 |
commit | 10a5fd5e6b7e2d464c9f95f67cade4ddbd63f4e1 (patch) | |
tree | eddf856286234f28cac747d20eb59d918e1bc8b5 /arch/um/os-Linux/mem.c | |
parent | c2a6585296009379e0f4eff39cdcb108b457ebf2 (diff) | |
parent | a145410dccdb44f81d3b56763ef9b6f721f4e47c (diff) |
Merge branch 'master'
Conflicts:
drivers/scsi/libata-scsi.c
include/linux/libata.h
Diffstat (limited to 'arch/um/os-Linux/mem.c')
-rw-r--r-- | 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 6ab372da9657..71bb90a7606d 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) | |||
53 | */ | 53 | */ |
54 | int make_tempfile(const char *template, char **out_tempname, int do_unlink) | 54 | int make_tempfile(const char *template, char **out_tempname, int do_unlink) |
55 | { | 55 | { |
56 | char tempname[MAXPATHLEN]; | 56 | char *tempname; |
57 | int fd; | 57 | int fd; |
58 | 58 | ||
59 | tempname = malloc(MAXPATHLEN); | ||
60 | |||
59 | find_tempdir(); | 61 | find_tempdir(); |
60 | if (*template != '/') | 62 | if (template[0] != '/') |
61 | strcpy(tempname, tempdir); | 63 | strcpy(tempname, tempdir); |
62 | else | 64 | else |
63 | *tempname = 0; | 65 | tempname[0] = '\0'; |
64 | strcat(tempname, template); | 66 | strcat(tempname, template); |
65 | fd = mkstemp(tempname); | 67 | fd = mkstemp(tempname); |
66 | if(fd < 0){ | 68 | if(fd < 0){ |
67 | fprintf(stderr, "open - cannot create %s: %s\n", tempname, | 69 | fprintf(stderr, "open - cannot create %s: %s\n", tempname, |
68 | strerror(errno)); | 70 | strerror(errno)); |
69 | return -1; | 71 | goto out; |
70 | } | 72 | } |
71 | if(do_unlink && (unlink(tempname) < 0)){ | 73 | if(do_unlink && (unlink(tempname) < 0)){ |
72 | perror("unlink"); | 74 | perror("unlink"); |
73 | return -1; | 75 | goto out; |
74 | } | 76 | } |
75 | if(out_tempname){ | 77 | if(out_tempname){ |
76 | *out_tempname = strdup(tempname); | 78 | *out_tempname = tempname; |
77 | if(*out_tempname == NULL){ | 79 | } else { |
78 | perror("strdup"); | 80 | free(tempname); |
79 | return -1; | ||
80 | } | ||
81 | } | 81 | } |
82 | return(fd); | 82 | return(fd); |
83 | out: | ||
84 | free(tempname); | ||
85 | return -1; | ||
83 | } | 86 | } |
84 | 87 | ||
85 | #define TEMPNAME_TEMPLATE "vm_file-XXXXXX" | 88 | #define TEMPNAME_TEMPLATE "vm_file-XXXXXX" |