]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
dir: use cleanup macro in dir_mount()
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 26 Mar 2020 14:32:29 +0000 (15:32 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Thu, 26 Mar 2020 14:32:29 +0000 (15:32 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/storage/dir.c

index d09e570ec9f6c88bab36e9cd45ba4e50d4d21ddb..b657cc0091cb50dfa347eee1c59430e7364c5e0e 100644 (file)
@@ -138,7 +138,7 @@ bool dir_detect(const char *path)
 
 int dir_mount(struct lxc_storage *bdev)
 {
-       char *mntdata = NULL;
+       __do_free char *mntdata = NULL;
        unsigned long mflags = 0, mntflags = 0, pflags = 0;
        int ret;
        const char *src;
@@ -152,14 +152,12 @@ int dir_mount(struct lxc_storage *bdev)
        ret = parse_mntopts(bdev->mntopts, &mntflags, &mntdata);
        if (ret < 0) {
                ERROR("Failed to parse mount options \"%s\"", bdev->mntopts);
-               free(mntdata);
                return -EINVAL;
        }
 
        ret = parse_propagationopts(bdev->mntopts, &pflags);
        if (ret < 0) {
                ERROR("Failed to parse propagation options \"%s\"", bdev->mntopts);
-               free(mntdata);
                return -EINVAL;
        }
 
@@ -175,12 +173,10 @@ int dir_mount(struct lxc_storage *bdev)
 
        if (ret < 0) {
                SYSERROR("Failed to mount \"%s\" on \"%s\"", src, bdev->dest);
-               free(mntdata);
                return -1;
        }
 
        TRACE("Mounted \"%s\" on \"%s\"", src, bdev->dest);
-       free(mntdata);
        return ret;
 }