coverity: #1425801

Resource leak Signed-off-by: 's avatarDonghwa Jeong <dh48.jeong@samsung.com>
parent 7177e6b1
......@@ -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;
}
......
......@@ -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;
}
......
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