Btrfs: fix incorrect {node,sector}size endianness from BTRFS_IOC_FS_INFO
authorOmar Sandoval <osandov@fb.com>
Wed, 23 Aug 2017 06:46:00 +0000 (23:46 -0700)
committerDavid Sterba <dsterba@suse.com>
Tue, 26 Sep 2017 12:48:50 +0000 (14:48 +0200)
fs_info->super_copy->{node,sector}size are little-endian, but the ioctl
should return the values in native endianness. Use the cached values in
btrfs_fs_info instead. Found with sparse.

Fixes: 80a773fbfc2d ("btrfs: retrieve more info from FS_INFO ioctl")
Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ioctl.c

index ae8fbf9d3de2ad0028ba2b1f5af81d4f3028f4ea..cf1c2ee030ddb05d6ffc63f4376272d352eb140e 100644 (file)
@@ -2769,9 +2769,9 @@ static long btrfs_ioctl_fs_info(struct btrfs_fs_info *fs_info,
        }
        mutex_unlock(&fs_devices->device_list_mutex);
 
-       fi_args->nodesize = fs_info->super_copy->nodesize;
-       fi_args->sectorsize = fs_info->super_copy->sectorsize;
-       fi_args->clone_alignment = fs_info->super_copy->sectorsize;
+       fi_args->nodesize = fs_info->nodesize;
+       fi_args->sectorsize = fs_info->sectorsize;
+       fi_args->clone_alignment = fs_info->sectorsize;
 
        if (copy_to_user(arg, fi_args, sizeof(*fi_args)))
                ret = -EFAULT;