diff options
author | Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> | 2006-02-24 16:03:56 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-02-24 17:31:37 -0500 |
commit | dc1561ac019ff7b6f75c5175abd2ec65c8dbd581 (patch) | |
tree | 4820ed1be1024c2f09382dbeade4f7c4e5a8b3e8 /arch/um/os-Linux | |
parent | 635dd50b7dc69b698e8808ff2802a6cfc31385a8 (diff) |
[PATCH] uml: os_connect_socket error path fixup
Fix an fd leak and a return of -1 instead of -errno in the error path - this
showed up in intensive testing of HPPFS, the os_connect_socket user.
Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Acked-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um/os-Linux')
-rw-r--r-- | arch/um/os-Linux/file.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/arch/um/os-Linux/file.c b/arch/um/os-Linux/file.c index f55773c819e6..3bd10deea280 100644 --- a/arch/um/os-Linux/file.c +++ b/arch/um/os-Linux/file.c | |||
@@ -272,14 +272,23 @@ int os_connect_socket(char *name) | |||
272 | snprintf(sock.sun_path, sizeof(sock.sun_path), "%s", name); | 272 | snprintf(sock.sun_path, sizeof(sock.sun_path), "%s", name); |
273 | 273 | ||
274 | fd = socket(AF_UNIX, SOCK_STREAM, 0); | 274 | fd = socket(AF_UNIX, SOCK_STREAM, 0); |
275 | if(fd < 0) | 275 | if(fd < 0) { |
276 | return(fd); | 276 | err = -errno; |
277 | goto out; | ||
278 | } | ||
277 | 279 | ||
278 | err = connect(fd, (struct sockaddr *) &sock, sizeof(sock)); | 280 | err = connect(fd, (struct sockaddr *) &sock, sizeof(sock)); |
279 | if(err) | 281 | if(err) { |
280 | return(-errno); | 282 | err = -errno; |
283 | goto out_close; | ||
284 | } | ||
281 | 285 | ||
282 | return(fd); | 286 | return fd; |
287 | |||
288 | out_close: | ||
289 | close(fd); | ||
290 | out: | ||
291 | return err; | ||
283 | } | 292 | } |
284 | 293 | ||
285 | void os_close_file(int fd) | 294 | void os_close_file(int fd) |