From: Paolo 'Blaisorblade' Giarrusso Date: Fri, 24 Feb 2006 21:03:56 +0000 (-0800) Subject: [PATCH] uml: os_connect_socket error path fixup X-Git-Tag: v2.6.16-rc5~45 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=dc1561ac019ff7b6f75c5175abd2ec65c8dbd581;p=linux-2.6-omap-h63xx.git [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 Acked-by: Jeff Dike Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/arch/um/os-Linux/file.c b/arch/um/os-Linux/file.c index f55773c819e..3bd10deea28 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) snprintf(sock.sun_path, sizeof(sock.sun_path), "%s", name); fd = socket(AF_UNIX, SOCK_STREAM, 0); - if(fd < 0) - return(fd); + if(fd < 0) { + err = -errno; + goto out; + } err = connect(fd, (struct sockaddr *) &sock, sizeof(sock)); - if(err) - return(-errno); + if(err) { + err = -errno; + goto out_close; + } - return(fd); + return fd; + +out_close: + close(fd); +out: + return err; } void os_close_file(int fd)