btrfs-progs: don't leak inherit on errors
authorZach Brown <zab@redhat.com>
Wed, 23 Jan 2013 23:18:14 +0000 (15:18 -0800)
committerZach Brown <zab@redhat.com>
Wed, 6 Feb 2013 00:09:40 +0000 (16:09 -0800)
A few paths returned errors before freeing their inherit allocation.

Signed-off-by: Zach Brown <zab@redhat.com>
cmds-subvolume.c

index a87bcc5..af04a6b 100644 (file)
@@ -158,13 +158,13 @@ static int cmd_subvol_create(int argc, char **argv)
        e = errno;
 
        close(fddst);
+       free(inherit);
 
        if(res < 0 ){
                fprintf( stderr, "ERROR: cannot create subvolume - %s\n",
                        strerror(e));
                return 11;
        }
-       free(inherit);
 
        return 0;
 }
@@ -604,13 +604,13 @@ static int cmd_snapshot(int argc, char **argv)
 
        close(fd);
        close(fddst);
+       free(inherit);
 
        if(res < 0 ){
                fprintf( stderr, "ERROR: cannot snapshot '%s' - %s\n",
                        subvol, strerror(e));
                return 11;
        }
-       free(inherit);
 
        return 0;
 }