mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 09:28:07 +02:00
util: fix possible fd leaks in os_socket_listen_abstract
Found by Coverity. Signed-off-by: Marcin Ślusarz <marcin.slusarz@intel.com> Fixes:ef5266ebd5("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> (cherry picked from commiteac0ba7fc1)
This commit is contained in:
parent
d0adfbc984
commit
75e81ff0d7
2 changed files with 8 additions and 3 deletions
|
|
@ -1822,7 +1822,7 @@
|
|||
"description": "util: fix possible fd leaks in os_socket_listen_abstract",
|
||||
"nominated": true,
|
||||
"nomination_type": 1,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"master_sha": null,
|
||||
"because_sha": "ef5266ebd50e7fa65c56bdb623e12ca8c233b470"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue