summaryrefslogtreecommitdiff
path: root/src/util/os_socket.c
diff options
context:
space:
mode:
authorMarcin Ślusarz <marcin.slusarz@intel.com>2020-07-24 17:51:25 +0200
committerMarge Bot <eric+marge@anholt.net>2020-07-30 10:41:00 +0000
commiteac0ba7fc193cceccd953bc4726ceef750b18085 (patch)
tree1bfaf47d7168ff5a22abd081612524eeb6fa2f6a /src/util/os_socket.c
parent62bfc700f74971db970748acf8b832dbee4c2805 (diff)
downloadmesa-eac0ba7fc193cceccd953bc4726ceef750b18085.tar.gz
mesa-eac0ba7fc193cceccd953bc4726ceef750b18085.tar.bz2
mesa-eac0ba7fc193cceccd953bc4726ceef750b18085.zip
util: fix possible fd leaks in os_socket_listen_abstract
Found by Coverity. Signed-off-by: Marcin Ślusarz <marcin.slusarz@intel.com> Fixes: ef5266ebd50 ("util/os_socket: Add socket related functions.") Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6067>
Diffstat (limited to 'src/util/os_socket.c')
-rw-r--r--src/util/os_socket.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/util/os_socket.c b/src/util/os_socket.c
index 98ef013205e..6562cccaddd 100644
--- a/src/util/os_socket.c
+++ b/src/util/os_socket.c
@@ -33,10 +33,15 @@ os_socket_listen_abstract(const char *path, int count)
int ret = bind(s, (struct sockaddr*)&addr,
offsetof(struct sockaddr_un, sun_path) +
strlen(path) + 1);
- if (ret < 0)
+ if (ret < 0) {
+ close(s);
return -1;
+ }
- listen(s, count);
+ if (listen(s, count) < 0) {
+ close(s);
+ return -1;
+ }
return s;
}