btrfs: add check to sysfs handler of label
authorDavid Sterba <dsterba@suse.com>
Tue, 26 Apr 2016 14:03:57 +0000 (16:03 +0200)
committerDavid Sterba <dsterba@suse.com>
Fri, 6 May 2016 13:22:49 +0000 (15:22 +0200)
Add a sanity check for the fs_info as we will dereference it, similar to
what the 'store features' handler does.

Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/sysfs.c

index 6a6bb60..3d14618 100644 (file)
@@ -377,6 +377,9 @@ static ssize_t btrfs_label_store(struct kobject *kobj,
        struct btrfs_fs_info *fs_info = to_fs_info(kobj);
        size_t p_len;
 
+       if (!fs_info)
+               return -EPERM;
+
        if (fs_info->sb->s_flags & MS_RDONLY)
                return -EROFS;