mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-12 22:36:32 +00:00
coverity resource leak fixes
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
This commit is contained in:
parent
5371906219
commit
00b6be440f
@ -36,6 +36,8 @@ again:
|
|||||||
f = fopen(path, "r");
|
f = fopen(path, "r");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
SYSERROR("opening %s\n", path);
|
SYSERROR("opening %s\n", path);
|
||||||
|
if (buf)
|
||||||
|
free(buf);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
sz += 1024;
|
sz += 1024;
|
||||||
|
@ -69,8 +69,10 @@ static char *mount_has_subsystem(const struct mntent *mntent)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* skip the first line, which contains column headings */
|
/* skip the first line, which contains column headings */
|
||||||
if (!fgets(line, MAXPATHLEN, f))
|
if (!fgets(line, MAXPATHLEN, f)) {
|
||||||
|
fclose(f);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
while (fgets(line, MAXPATHLEN, f)) {
|
while (fgets(line, MAXPATHLEN, f)) {
|
||||||
c = strchr(line, '\t');
|
c = strchr(line, '\t');
|
||||||
|
@ -309,6 +309,7 @@ static int run_buffer(char *buffer)
|
|||||||
output = malloc(LXC_LOG_BUFFER_SIZE);
|
output = malloc(LXC_LOG_BUFFER_SIZE);
|
||||||
if (!output) {
|
if (!output) {
|
||||||
ERROR("failed to allocate memory for script output");
|
ERROR("failed to allocate memory for script output");
|
||||||
|
pclose(f);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -535,6 +536,7 @@ static int mount_rootfs_file(const char *rootfs, const char *target)
|
|||||||
if (errno != ENXIO) {
|
if (errno != ENXIO) {
|
||||||
WARN("unexpected error for ioctl on '%s': %m",
|
WARN("unexpected error for ioctl on '%s': %m",
|
||||||
direntp->d_name);
|
direntp->d_name);
|
||||||
|
close(fd);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -792,6 +794,7 @@ static int setup_rootfs_pivot_root_cb(char *buffer, void *data)
|
|||||||
listentry->elem = strdup(mountpoint);
|
listentry->elem = strdup(mountpoint);
|
||||||
if (!listentry->elem) {
|
if (!listentry->elem) {
|
||||||
SYSERROR("strdup failed");
|
SYSERROR("strdup failed");
|
||||||
|
free(listentry);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
lxc_list_add_tail(mountlist, listentry);
|
lxc_list_add_tail(mountlist, listentry);
|
||||||
@ -1053,8 +1056,10 @@ int detect_shared_rootfs(void)
|
|||||||
if (strcmp(p+1, "/") == 0) {
|
if (strcmp(p+1, "/") == 0) {
|
||||||
// this is '/'. is it shared?
|
// this is '/'. is it shared?
|
||||||
p = index(p2+1, ' ');
|
p = index(p2+1, ' ');
|
||||||
if (strstr(p, "shared:"))
|
if (strstr(p, "shared:")) {
|
||||||
|
fclose(f);
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
@ -1249,8 +1249,10 @@ static int config_mount(const char *key, const char *value,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
mntelem = strdup(value);
|
mntelem = strdup(value);
|
||||||
if (!mntelem)
|
if (!mntelem) {
|
||||||
|
free(mntlist);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
mntlist->elem = mntelem;
|
mntlist->elem = mntelem;
|
||||||
|
|
||||||
lxc_list_add_tail(&lxc_conf->mount_list, mntlist);
|
lxc_list_add_tail(&lxc_conf->mount_list, mntlist);
|
||||||
|
Loading…
Reference in New Issue
Block a user