[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202206101159.fXYW8bYv-lkp@intel.com>
Date: Fri, 10 Jun 2022 09:27:56 +0300
From: Dan Carpenter <dan.carpenter@...cle.com>
To: kbuild@...ts.01.org, Stefan Roesch <shr@...com>
Cc: lkp@...el.com, kbuild-all@...ts.01.org,
linux-kernel@...r.kernel.org, David Sterba <dsterba@...e.com>
Subject: [fdmanana:misc-next 36/71] fs/btrfs/sysfs.c:811
btrfs_force_chunk_alloc_store() warn: passing zero to 'PTR_ERR'
tree: https://git.kernel.org/pub/scm/linux/kernel/git/fdmanana/linux.git misc-next
head: e2a46f3f73fd5aac0241242d535905286a947113
commit: 46e1bce0ac340396474e5f604c2acb6644175854 [36/71] btrfs: sysfs: add force_chunk_alloc trigger to force allocation
config: m68k-randconfig-m031-20220608 (https://download.01.org/0day-ci/archive/20220610/202206101159.fXYW8bYv-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 11.3.0
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@...el.com>
Reported-by: Dan Carpenter <dan.carpenter@...cle.com>
smatch warnings:
fs/btrfs/sysfs.c:811 btrfs_force_chunk_alloc_store() warn: passing zero to 'PTR_ERR'
vim +/PTR_ERR +811 fs/btrfs/sysfs.c
46e1bce0ac3403 Stefan Roesch 2022-02-08 782 static ssize_t btrfs_force_chunk_alloc_store(struct kobject *kobj,
46e1bce0ac3403 Stefan Roesch 2022-02-08 783 struct kobj_attribute *a,
46e1bce0ac3403 Stefan Roesch 2022-02-08 784 const char *buf, size_t len)
46e1bce0ac3403 Stefan Roesch 2022-02-08 785 {
46e1bce0ac3403 Stefan Roesch 2022-02-08 786 struct btrfs_space_info *space_info = to_space_info(kobj);
46e1bce0ac3403 Stefan Roesch 2022-02-08 787 struct btrfs_fs_info *fs_info = to_fs_info(get_btrfs_kobj(kobj));
46e1bce0ac3403 Stefan Roesch 2022-02-08 788 struct btrfs_trans_handle *trans;
46e1bce0ac3403 Stefan Roesch 2022-02-08 789 bool val;
46e1bce0ac3403 Stefan Roesch 2022-02-08 790 int ret;
46e1bce0ac3403 Stefan Roesch 2022-02-08 791
46e1bce0ac3403 Stefan Roesch 2022-02-08 792 if (!capable(CAP_SYS_ADMIN))
46e1bce0ac3403 Stefan Roesch 2022-02-08 793 return -EPERM;
46e1bce0ac3403 Stefan Roesch 2022-02-08 794
46e1bce0ac3403 Stefan Roesch 2022-02-08 795 if (sb_rdonly(fs_info->sb))
46e1bce0ac3403 Stefan Roesch 2022-02-08 796 return -EROFS;
46e1bce0ac3403 Stefan Roesch 2022-02-08 797
46e1bce0ac3403 Stefan Roesch 2022-02-08 798 ret = kstrtobool(buf, &val);
46e1bce0ac3403 Stefan Roesch 2022-02-08 799 if (ret)
46e1bce0ac3403 Stefan Roesch 2022-02-08 800 return ret;
46e1bce0ac3403 Stefan Roesch 2022-02-08 801
46e1bce0ac3403 Stefan Roesch 2022-02-08 802 if (!val)
46e1bce0ac3403 Stefan Roesch 2022-02-08 803 return -EINVAL;
46e1bce0ac3403 Stefan Roesch 2022-02-08 804
46e1bce0ac3403 Stefan Roesch 2022-02-08 805 /*
46e1bce0ac3403 Stefan Roesch 2022-02-08 806 * This is unsafe to be called from sysfs context and may cause
46e1bce0ac3403 Stefan Roesch 2022-02-08 807 * unexpected problems.
46e1bce0ac3403 Stefan Roesch 2022-02-08 808 */
46e1bce0ac3403 Stefan Roesch 2022-02-08 809 trans = btrfs_start_transaction(fs_info->tree_root, 0);
46e1bce0ac3403 Stefan Roesch 2022-02-08 810 if (!trans)
46e1bce0ac3403 Stefan Roesch 2022-02-08 @811 return PTR_ERR(trans);
PTR_ERR(NULL) means success.
46e1bce0ac3403 Stefan Roesch 2022-02-08 812 ret = btrfs_force_chunk_alloc(trans, space_info->flags);
46e1bce0ac3403 Stefan Roesch 2022-02-08 813 btrfs_end_transaction(trans);
46e1bce0ac3403 Stefan Roesch 2022-02-08 814
46e1bce0ac3403 Stefan Roesch 2022-02-08 815 if (ret == 1)
46e1bce0ac3403 Stefan Roesch 2022-02-08 816 return len;
46e1bce0ac3403 Stefan Roesch 2022-02-08 817
46e1bce0ac3403 Stefan Roesch 2022-02-08 818 return -ENOSPC;
46e1bce0ac3403 Stefan Roesch 2022-02-08 819 }
--
0-DAY CI Kernel Test Service
https://01.org/lkp
Powered by blists - more mailing lists