]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
coverity: #1425801 2394/head
authorDonghwa Jeong <dh48.jeong@samsung.com>
Mon, 11 Jun 2018 06:13:58 +0000 (15:13 +0900)
committerDonghwa Jeong <dh48.jeong@samsung.com>
Mon, 11 Jun 2018 06:13:58 +0000 (15:13 +0900)
Resource leak

Signed-off-by: Donghwa Jeong <dh48.jeong@samsung.com>
src/lxc/monitor.c
src/lxc/tools/lxc_monitor.c

index 3aacf22eadc3381d0a065ef37903d867b14e4591..e410bede4320055dba3b3939dbdf9c4a0c041e21 100644 (file)
@@ -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;
        }
 
index 2d7f91bd4257349d1dad486b8f300fc283dcdc42..8d9b7e63c261e3afafa97190726e0cd1a87406db 100644 (file)
@@ -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;
        }