diff options
author | Zdenek Kabelac <zkabelac@redhat.com> | 2012-12-14 21:31:22 +0100 |
---|---|---|
committer | Zdenek Kabelac <zkabelac@redhat.com> | 2012-12-15 17:23:27 +0100 |
commit | 4008f4f891c948c1629ed0ee50e04d4c26001d0c (patch) | |
tree | 1b1d70463f197a6a001d5a696c26bca354f1a6ff /libdaemon | |
parent | e012d0635d34edd98652c9425abb618a9565077a (diff) | |
download | lvm2-4008f4f891c948c1629ed0ee50e04d4c26001d0c.tar.gz |
lvmetad: fix socket leak in handle_connect
Close socket_fd and report error on malloc failure.
Diffstat (limited to 'libdaemon')
-rw-r--r-- | libdaemon/server/daemon-server.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/libdaemon/server/daemon-server.c b/libdaemon/server/daemon-server.c index 3711419c6..3c84e1170 100644 --- a/libdaemon/server/daemon-server.c +++ b/libdaemon/server/daemon-server.c @@ -427,8 +427,12 @@ static int handle_connect(daemon_state s) if (client.socket_fd < 0) return 0; - if (!(baton = malloc(sizeof(struct thread_baton)))) + if (!(baton = malloc(sizeof(struct thread_baton)))) { + if (close(client.socket_fd)) + perror("close"); + ERROR(&s, "Failed to allocate thread baton"); return 0; + } baton->s = s; baton->client = client; |