From: "Paolo 'Blaisorblade' Giarrusso" <blaisorblade@yahoo.it>
To: Andrew Morton <akpm@osdl.org>
Cc: Jeff Dike <jdike@addtoit.com>,
linux-kernel@vger.kernel.org,
user-mode-linux-devel@lists.sourceforge.net
Subject: [uml-devel] [PATCH 4/6] uml: os_connect_socket error path fixup
Date: Tue, 21 Feb 2006 18:16:27 +0100 [thread overview]
Message-ID: <20060221171627.509.95340.stgit@zion.home.lan> (raw)
In-Reply-To: <20060221171535.509.28286.stgit@zion.home.lan>
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>
---
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 f55773c..3bd10de 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)
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
next prev parent reply other threads:[~2006-02-21 17:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-21 17:15 [uml-devel] [PATCH 0/6] UML little patches for 2.6.16 Paolo 'Blaisorblade' Giarrusso
2006-02-21 17:16 ` [uml-devel] [PATCH 1/6] uml: correct error messages in COW driver Paolo 'Blaisorblade' Giarrusso
2006-02-21 17:16 ` [uml-devel] [PATCH 2/6] uml: fix usage of kernel_errno in place of errno Paolo 'Blaisorblade' Giarrusso
2006-02-21 17:16 ` [uml-devel] [PATCH 3/6] uml: fix ((unused)) attribute Paolo 'Blaisorblade' Giarrusso
2006-02-21 17:16 ` Paolo 'Blaisorblade' Giarrusso [this message]
2006-02-21 17:16 ` [uml-devel] [PATCH 5/6] uml: better error reporting for read_output Paolo 'Blaisorblade' Giarrusso
2006-02-21 17:16 ` [uml-devel] [PATCH 6/6] uml: tidying COW code Paolo 'Blaisorblade' Giarrusso
2006-02-21 20:49 ` [uml-devel] Re: [PATCH 0/6] UML little patches for 2.6.16 Jeff Dike
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060221171627.509.95340.stgit@zion.home.lan \
--to=blaisorblade@yahoo.it \
--cc=akpm@osdl.org \
--cc=jdike@addtoit.com \
--cc=linux-kernel@vger.kernel.org \
--cc=user-mode-linux-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox