]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
criu: use cleanup macro when parsing mount data
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 10 Feb 2021 11:46:08 +0000 (12:46 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 10 Feb 2021 11:52:30 +0000 (12:52 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/criu.c

index 7a3e3dda95b1c88a0b3c37c70494b2fba97380a5..c8e51a8d783d678fb900b1a1a58ff09089c40c69 100644 (file)
@@ -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);