From 928388738b2b8dfba0fa99dd8f77dfb466df8af4 Mon Sep 17 00:00:00 2001 From: Donghwa Jeong Date: Mon, 11 Jun 2018 15:13:58 +0900 Subject: [PATCH] coverity: #1425801 Resource leak Signed-off-by: Donghwa Jeong --- src/lxc/monitor.c | 7 ------- src/lxc/tools/lxc_monitor.c | 7 ------- 2 files changed, 14 deletions(-) diff --git a/src/lxc/monitor.c b/src/lxc/monitor.c index 3aacf22ead..e410bede43 100644 --- a/src/lxc/monitor.c +++ b/src/lxc/monitor.c @@ -216,18 +216,11 @@ int lxc_monitor_open(const char *lxcpath) if (lxc_monitor_sock_name(lxcpath, &addr) < 0) return -1; - fd = socket(PF_UNIX, SOCK_STREAM, 0); - if (fd < 0) { - ERROR("Failed to create socket: %s.", strerror(errno)); - return -1; - } - len = strlen(&addr.sun_path[1]); DEBUG("opening monitor socket %s with len %zu", &addr.sun_path[1], len); if (len >= sizeof(addr.sun_path) - 1) { errno = ENAMETOOLONG; ERROR("name of monitor socket too long (%zu bytes): %s", len, strerror(errno)); - close(fd); return -1; } diff --git a/src/lxc/tools/lxc_monitor.c b/src/lxc/tools/lxc_monitor.c index 2d7f91bd42..8d9b7e63c2 100644 --- a/src/lxc/tools/lxc_monitor.c +++ b/src/lxc/tools/lxc_monitor.c @@ -342,16 +342,9 @@ static int lxc_monitor_open(const char *lxcpath) if (lxc_monitor_sock_name(lxcpath, &addr) < 0) return -1; - fd = socket(PF_UNIX, SOCK_STREAM, 0); - if (fd < 0) { - fprintf(stderr, "Failed to create socket: %s\n", strerror(errno)); - return -errno; - } - len = strlen(&addr.sun_path[1]); if (len >= sizeof(addr.sun_path) - 1) { errno = ENAMETOOLONG; - close(fd); fprintf(stderr, "name of monitor socket too long (%zu bytes): %s\n", len, strerror(errno)); return -errno; }