diff options
author | Jesper Juhl <jj@chaosbits.net> | 2012-08-08 20:56:14 +0200 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2012-09-01 09:58:59 -0700 |
commit | 0de4b95409367f5012ff5be7fd3785dc11c6cda8 (patch) | |
tree | 57b97d9ccec8fe8a403f7d3040469d7370b58662 /Documentation/accounting | |
parent | 5ffd27fa8d7950a3c2136100860273e6ff2605e0 (diff) | |
download | linux-3.10-0de4b95409367f5012ff5be7fd3785dc11c6cda8.tar.gz linux-3.10-0de4b95409367f5012ff5be7fd3785dc11c6cda8.tar.bz2 linux-3.10-0de4b95409367f5012ff5be7fd3785dc11c6cda8.zip |
doc: getdelays.c: remember to close() socket on error in create_nl_socket()
If the call to setsockopt() fails in
Documentation/accounting/getdelays.c::create_nl_socket() we return -1
without closing the socket, thus leaking it when the 'fd' variable
goes out of scope.
Easily fixed by just jumping to the 'error' label instead of returning
since we do the proper cleanup there.
While I was there I noticed that the error message that is printet if
setsockopt() fails was broken over two lines - put that on a single
line so it is easier to grep for.
Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'Documentation/accounting')
-rw-r--r-- | Documentation/accounting/getdelays.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/Documentation/accounting/getdelays.c b/Documentation/accounting/getdelays.c index f6318f6d7ba..6f706aca204 100644 --- a/Documentation/accounting/getdelays.c +++ b/Documentation/accounting/getdelays.c @@ -98,10 +98,9 @@ static int create_nl_socket(int protocol) if (rcvbufsz) if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &rcvbufsz, sizeof(rcvbufsz)) < 0) { - fprintf(stderr, "Unable to set socket rcv buf size " - "to %d\n", + fprintf(stderr, "Unable to set socket rcv buf size to %d\n", rcvbufsz); - return -1; + goto error; } memset(&local, 0, sizeof(local)); |