From: Christian Brauner Date: Wed, 10 Feb 2021 11:46:08 +0000 (+0100) Subject: criu: use cleanup macro when parsing mount data X-Git-Tag: lxc-5.0.0~294^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5257b91b6e6ba7ea8e865a602b1cd790d44a9c69;p=thirdparty%2Flxc.git criu: use cleanup macro when parsing mount data Signed-off-by: Christian Brauner --- diff --git a/src/lxc/criu.c b/src/lxc/criu.c index 7a3e3dda9..c8e51a8d7 100644 --- a/src/lxc/criu.c +++ b/src/lxc/criu.c @@ -350,28 +350,23 @@ static int exec_criu(struct cgroup_ops *cgroup_ops, struct lxc_conf *conf, return log_error_errno(-ENOENT, ENOENT, "Failed to create anonymous mount file"); while (getmntent_r(f_mnt, &mntent, buf, sizeof(buf))) { + __do_free char *mnt_options = NULL; unsigned long flags = 0; - char *mntdata = NULL; char arg[2 * PATH_MAX + 2]; - if (parse_mntopts(mntent.mnt_opts, &flags, &mntdata) < 0) + if (parse_mntopts(mntent.mnt_opts, &flags, &mnt_options) < 0) return log_error_errno(-EINVAL, EINVAL, "Failed to parse mount options"); - free(mntdata); - /* only add --ext-mount-map for actual bind mounts */ if (!(flags & MS_BIND)) continue; if (strcmp(opts->action, "dump") == 0) - ret = snprintf(arg, sizeof(arg), "/%s:%s", - mntent.mnt_dir, mntent.mnt_dir); + ret = snprintf(arg, sizeof(arg), "/%s:%s", mntent.mnt_dir, mntent.mnt_dir); else - ret = snprintf(arg, sizeof(arg), "%s:%s", - mntent.mnt_dir, mntent.mnt_fsname); - if (ret < 0 || ret >= sizeof(arg)) { + ret = snprintf(arg, sizeof(arg), "%s:%s", mntent.mnt_dir, mntent.mnt_fsname); + if (ret < 0 || ret >= sizeof(arg)) return log_error_errno(-EIO, EIO, "Failed to create mount entry"); - } DECLARE_ARG("--ext-mount-map"); DECLARE_ARG(arg);