From: Donghwa Jeong Date: Mon, 11 Jun 2018 06:13:58 +0000 (+0900) Subject: coverity: #1425801 X-Git-Tag: lxc-3.1.0~258^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F2394%2Fhead;p=thirdparty%2Flxc.git coverity: #1425801 Resource leak Signed-off-by: Donghwa Jeong --- diff --git a/src/lxc/monitor.c b/src/lxc/monitor.c index 3aacf22ea..e410bede4 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 2d7f91bd4..8d9b7e63c 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; }