mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-03 07:10:15 +01: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>
This commit is contained in:
parent
62bfc700f7
commit
eac0ba7fc1
1 changed files with 7 additions and 2 deletions
|
|
@ -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