[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>
This commit is contained in:
parent
635dd50b7d
commit
dc1561ac01
1 changed files with 14 additions and 5 deletions
|
@ -272,14 +272,23 @@ int os_connect_socket(char *name)
|
||||||
snprintf(sock.sun_path, sizeof(sock.sun_path), "%s", name);
|
snprintf(sock.sun_path, sizeof(sock.sun_path), "%s", name);
|
||||||
|
|
||||||
fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||||
if(fd < 0)
|
if(fd < 0) {
|
||||||
return(fd);
|
err = -errno;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
err = connect(fd, (struct sockaddr *) &sock, sizeof(sock));
|
err = connect(fd, (struct sockaddr *) &sock, sizeof(sock));
|
||||||
if(err)
|
if(err) {
|
||||||
return(-errno);
|
err = -errno;
|
||||||
|
goto out_close;
|
||||||
|
}
|
||||||
|
|
||||||
return(fd);
|
return fd;
|
||||||
|
|
||||||
|
out_close:
|
||||||
|
close(fd);
|
||||||
|
out:
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
void os_close_file(int fd)
|
void os_close_file(int fd)
|
||||||
|
|
Loading…
Reference in a new issue