coverity: #1425734

free memory on error Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent d125f48c
...@@ -4337,7 +4337,7 @@ WRAP_API_2(bool, lxcapi_detach_interface, const char *, const char *) ...@@ -4337,7 +4337,7 @@ WRAP_API_2(bool, lxcapi_detach_interface, const char *, const char *)
static int do_lxcapi_migrate(struct lxc_container *c, unsigned int cmd, static int do_lxcapi_migrate(struct lxc_container *c, unsigned int cmd,
struct migrate_opts *opts, unsigned int size) struct migrate_opts *opts, unsigned int size)
{ {
int ret; int ret = -1;
struct migrate_opts *valid_opts = opts; struct migrate_opts *valid_opts = opts;
/* If the caller has a bigger (newer) struct migrate_opts, let's make /* If the caller has a bigger (newer) struct migrate_opts, let's make
...@@ -4374,21 +4374,21 @@ static int do_lxcapi_migrate(struct lxc_container *c, unsigned int cmd, ...@@ -4374,21 +4374,21 @@ static int do_lxcapi_migrate(struct lxc_container *c, unsigned int cmd,
case MIGRATE_PRE_DUMP: case MIGRATE_PRE_DUMP:
if (!do_lxcapi_is_running(c)) { if (!do_lxcapi_is_running(c)) {
ERROR("container is not running"); ERROR("container is not running");
return false; goto on_error;
} }
ret = !__criu_pre_dump(c, valid_opts); ret = !__criu_pre_dump(c, valid_opts);
break; break;
case MIGRATE_DUMP: case MIGRATE_DUMP:
if (!do_lxcapi_is_running(c)) { if (!do_lxcapi_is_running(c)) {
ERROR("container is not running"); ERROR("container is not running");
return false; goto on_error;
} }
ret = !__criu_dump(c, valid_opts); ret = !__criu_dump(c, valid_opts);
break; break;
case MIGRATE_RESTORE: case MIGRATE_RESTORE:
if (do_lxcapi_is_running(c)) { if (do_lxcapi_is_running(c)) {
ERROR("container is already running"); ERROR("container is already running");
return false; goto on_error;
} }
ret = !__criu_restore(c, valid_opts); ret = !__criu_restore(c, valid_opts);
break; break;
...@@ -4397,6 +4397,7 @@ static int do_lxcapi_migrate(struct lxc_container *c, unsigned int cmd, ...@@ -4397,6 +4397,7 @@ static int do_lxcapi_migrate(struct lxc_container *c, unsigned int cmd,
ret = -EINVAL; ret = -EINVAL;
} }
on_error:
if (size < sizeof(*opts)) if (size < sizeof(*opts))
free(valid_opts); free(valid_opts);
......
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