Unverified Commit 61e9751f by Christian Brauner Committed by GitHub

Merge pull request #3280 from Piscolero/state_client_socket_leak_fix

commands_utils: fix socket leak when adding state client
parents d31059ef ebbca852
...@@ -863,7 +863,7 @@ int lxc_cmd_add_state_client(const char *name, const char *lxcpath, ...@@ -863,7 +863,7 @@ int lxc_cmd_add_state_client(const char *name, const char *lxcpath,
return MAX_STATE; return MAX_STATE;
} }
static int lxc_cmd_add_state_client_callback(int fd, struct lxc_cmd_req *req, static int lxc_cmd_add_state_client_callback(__owns int fd, struct lxc_cmd_req *req,
struct lxc_handler *handler, struct lxc_handler *handler,
struct lxc_epoll_descr *descr) struct lxc_epoll_descr *descr)
{ {
...@@ -889,6 +889,10 @@ static int lxc_cmd_add_state_client_callback(int fd, struct lxc_cmd_req *req, ...@@ -889,6 +889,10 @@ static int lxc_cmd_add_state_client_callback(int fd, struct lxc_cmd_req *req,
if (ret < 0) if (ret < 0)
goto reap_client_fd; goto reap_client_fd;
/* close fd if state is already achieved to avoid leakage */
if (rsp.ret != MAX_STATE)
close(fd);
return 0; return 0;
reap_client_fd: reap_client_fd:
......
...@@ -52,6 +52,9 @@ ...@@ -52,6 +52,9 @@
#define __lxc_unused #define __lxc_unused
#endif #endif
/* Indicates taking ownership */
#define __owns
#define __cgfsng_ops #define __cgfsng_ops
#endif /* __LXC_COMPILER_H */ #endif /* __LXC_COMPILER_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment