diff options
author | Gonglei <arei.gonglei@huawei.com> | 2014-11-13 20:17:06 +0800 |
---|---|---|
committer | Michael Tokarev <mjt@tls.msk.ru> | 2015-02-10 09:27:20 +0300 |
commit | 88ea8ed74cb6956f43199a098ca4963ae73bba57 (patch) | |
tree | b5fb2600aa61f05577381c49be38f673e5ec032f /fsdev/virtfs-proxy-helper.c | |
parent | 46ede58bb461c1171251988e7fb1db6590350975 (diff) |
virtfs-proxy-helper: Fix possible socket leak.
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Diffstat (limited to 'fsdev/virtfs-proxy-helper.c')
-rw-r--r-- | fsdev/virtfs-proxy-helper.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c index cd291d32f2..c1da2d78e7 100644 --- a/fsdev/virtfs-proxy-helper.c +++ b/fsdev/virtfs-proxy-helper.c @@ -749,24 +749,29 @@ static int proxy_socket(const char *path, uid_t uid, gid_t gid) if (bind(sock, (struct sockaddr *)&proxy, sizeof(struct sockaddr_un)) < 0) { do_perror("bind"); - return -1; + goto error; } if (chown(proxy.sun_path, uid, gid) < 0) { do_perror("chown"); - return -1; + goto error; } if (listen(sock, 1) < 0) { do_perror("listen"); - return -1; + goto error; } size = sizeof(qemu); client = accept(sock, (struct sockaddr *)&qemu, &size); if (client < 0) { do_perror("accept"); - return -1; + goto error; } + close(sock); return client; + +error: + close(sock); + return -1; } static void usage(char *prog) |