btrfs-progs: fi show, don't leak canonical path
authorDavid Sterba <dsterba@suse.cz>
Tue, 30 Dec 2014 14:01:13 +0000 (15:01 +0100)
committerDavid Sterba <dsterba@suse.cz>
Tue, 30 Dec 2014 14:48:54 +0000 (15:48 +0100)
Resolves-coverity-id: 1260252
Signed-off-by: David Sterba <dsterba@suse.cz>
cmds-filesystem.c

index 80875ff..1c1d34a 100644 (file)
@@ -471,7 +471,6 @@ static int print_one_fs(struct btrfs_ioctl_fs_info_args *fs_info,
                char *canonical_path;
 
                tmp_dev_info = (struct btrfs_ioctl_dev_info_args *)&dev_info[i];
-               canonical_path = canonicalize_path((char *)tmp_dev_info->path);
 
                /* Add check for missing devices even mounted */
                fd = open((char *)tmp_dev_info->path, O_RDONLY);
@@ -480,6 +479,7 @@ static int print_one_fs(struct btrfs_ioctl_fs_info_args *fs_info,
                        continue;
                }
                close(fd);
+               canonical_path = canonicalize_path((char *)tmp_dev_info->path);
                printf("\tdevid %4llu size %s used %s path %s\n",
                        tmp_dev_info->devid,
                        pretty_size(tmp_dev_info->total_bytes),