coverity: #1425781

Resource leak Signed-off-by: 's avatarDonghwa Jeong <dh48.jeong@samsung.com>
parent 8f55c742
...@@ -868,14 +868,14 @@ static bool criu_ok(struct lxc_container *c, char **criu_version) ...@@ -868,14 +868,14 @@ static bool criu_ok(struct lxc_container *c, char **criu_version)
{ {
struct lxc_list *it; struct lxc_list *it;
if (!criu_version_ok(criu_version))
return false;
if (geteuid()) { if (geteuid()) {
ERROR("Must be root to checkpoint"); ERROR("Must be root to checkpoint");
return false; return false;
} }
if (!criu_version_ok(criu_version))
return false;
/* We only know how to restore containers with veth networks. */ /* We only know how to restore containers with veth networks. */
lxc_list_for_each(it, &c->lxc_conf->network) { lxc_list_for_each(it, &c->lxc_conf->network) {
struct lxc_netdev *n = it->elem; struct lxc_netdev *n = it->elem;
...@@ -887,6 +887,10 @@ static bool criu_ok(struct lxc_container *c, char **criu_version) ...@@ -887,6 +887,10 @@ static bool criu_ok(struct lxc_container *c, char **criu_version)
break; break;
default: default:
ERROR("Found un-dumpable network: %s (%s)", lxc_net_type_to_str(n->type), n->name); ERROR("Found un-dumpable network: %s (%s)", lxc_net_type_to_str(n->type), n->name);
if (criu_version) {
free(*criu_version);
*criu_version = NULL;
}
return false; return false;
} }
} }
...@@ -1239,6 +1243,7 @@ static bool do_dump(struct lxc_container *c, char *mode, struct migrate_opts *op ...@@ -1239,6 +1243,7 @@ static bool do_dump(struct lxc_container *c, char *mode, struct migrate_opts *op
ret = pipe(criuout); ret = pipe(criuout);
if (ret < 0) { if (ret < 0) {
SYSERROR("pipe() failed"); SYSERROR("pipe() failed");
free(criu_version);
return false; return false;
} }
...@@ -1299,6 +1304,7 @@ static bool do_dump(struct lxc_container *c, char *mode, struct migrate_opts *op ...@@ -1299,6 +1304,7 @@ static bool do_dump(struct lxc_container *c, char *mode, struct migrate_opts *op
if (w == -1) { if (w == -1) {
SYSERROR("waitpid"); SYSERROR("waitpid");
close(criuout[0]); close(criuout[0]);
free(criu_version);
return false; return false;
} }
...@@ -1327,6 +1333,8 @@ static bool do_dump(struct lxc_container *c, char *mode, struct migrate_opts *op ...@@ -1327,6 +1333,8 @@ static bool do_dump(struct lxc_container *c, char *mode, struct migrate_opts *op
if (!ret) if (!ret)
ERROR("criu output: %s", buf); ERROR("criu output: %s", buf);
free(criu_version);
return ret; return ret;
} }
fail: fail:
...@@ -1366,9 +1374,6 @@ bool __criu_restore(struct lxc_container *c, struct migrate_opts *opts) ...@@ -1366,9 +1374,6 @@ bool __criu_restore(struct lxc_container *c, struct migrate_opts *opts)
int pipefd[2]; int pipefd[2];
char *criu_version = NULL; char *criu_version = NULL;
if (!criu_ok(c, &criu_version))
return false;
if (geteuid()) { if (geteuid()) {
ERROR("Must be root to restore"); ERROR("Must be root to restore");
return false; return false;
...@@ -1379,10 +1384,17 @@ bool __criu_restore(struct lxc_container *c, struct migrate_opts *opts) ...@@ -1379,10 +1384,17 @@ bool __criu_restore(struct lxc_container *c, struct migrate_opts *opts)
return false; return false;
} }
if (!criu_ok(c, &criu_version)) {
close(pipefd[0]);
close(pipefd[1]);
return false;
}
pid = fork(); pid = fork();
if (pid < 0) { if (pid < 0) {
close(pipefd[0]); close(pipefd[0]);
close(pipefd[1]); close(pipefd[1]);
free(criu_version);
return false; return false;
} }
...@@ -1393,6 +1405,7 @@ bool __criu_restore(struct lxc_container *c, struct migrate_opts *opts) ...@@ -1393,6 +1405,7 @@ bool __criu_restore(struct lxc_container *c, struct migrate_opts *opts)
} }
close(pipefd[1]); close(pipefd[1]);
free(criu_version);
nread = read(pipefd[0], &status, sizeof(status)); nread = read(pipefd[0], &status, sizeof(status));
close(pipefd[0]); close(pipefd[0]);
......
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