* [kdave-btrfs-devel:for-next-20220401 96/102] fs/btrfs/sysfs.c:830 btrfs_force_chunk_alloc_store() warn: passing zero to 'PTR_ERR'
@ 2022-04-04 13:40 Dan Carpenter
2022-04-04 14:25 ` David Sterba
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2022-04-04 13:40 UTC (permalink / raw)
To: kbuild, Stefan Roesch; +Cc: lkp, kbuild-all, linux-kernel, David Sterba
tree: https://github.com/kdave/btrfs-devel.git for-next-20220401
head: 0c593f04d2f520a720c5c618ba9fe0355d08bba8
commit: 6e115adef2b6a9b9a7cc25414e1b8f4414e02044 [96/102] btrfs: add force_chunk_alloc sysfs entry to force allocation
config: nios2-randconfig-m031-20220403 (https://download.01.org/0day-ci/archive/20220403/202204030841.qWK5rMDU-lkp@intel.com/config)
compiler: nios2-linux-gcc (GCC) 11.2.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
New smatch warnings:
fs/btrfs/sysfs.c:830 btrfs_force_chunk_alloc_store() warn: passing zero to 'PTR_ERR'
vim +/PTR_ERR +830 fs/btrfs/sysfs.c
6e115adef2b6a9 Stefan Roesch 2021-12-03 797 static ssize_t btrfs_force_chunk_alloc_store(struct kobject *kobj,
6e115adef2b6a9 Stefan Roesch 2021-12-03 798 struct kobj_attribute *a,
6e115adef2b6a9 Stefan Roesch 2021-12-03 799 const char *buf, size_t len)
6e115adef2b6a9 Stefan Roesch 2021-12-03 800 {
6e115adef2b6a9 Stefan Roesch 2021-12-03 801 struct btrfs_space_info *space_info = to_space_info(kobj);
6e115adef2b6a9 Stefan Roesch 2021-12-03 802 struct btrfs_fs_info *fs_info = to_fs_info(get_btrfs_kobj(kobj));
6e115adef2b6a9 Stefan Roesch 2021-12-03 803 struct btrfs_trans_handle *trans;
6e115adef2b6a9 Stefan Roesch 2021-12-03 804 unsigned long val;
6e115adef2b6a9 Stefan Roesch 2021-12-03 805 int ret;
6e115adef2b6a9 Stefan Roesch 2021-12-03 806
6e115adef2b6a9 Stefan Roesch 2021-12-03 807 if (!fs_info) {
6e115adef2b6a9 Stefan Roesch 2021-12-03 808 pr_err("couldn't get fs_info\n");
6e115adef2b6a9 Stefan Roesch 2021-12-03 809 return -EPERM;
6e115adef2b6a9 Stefan Roesch 2021-12-03 810 }
6e115adef2b6a9 Stefan Roesch 2021-12-03 811
6e115adef2b6a9 Stefan Roesch 2021-12-03 812 if (!capable(CAP_SYS_ADMIN))
6e115adef2b6a9 Stefan Roesch 2021-12-03 813 return -EPERM;
6e115adef2b6a9 Stefan Roesch 2021-12-03 814
6e115adef2b6a9 Stefan Roesch 2021-12-03 815 if (sb_rdonly(fs_info->sb))
6e115adef2b6a9 Stefan Roesch 2021-12-03 816 return -EROFS;
6e115adef2b6a9 Stefan Roesch 2021-12-03 817
6e115adef2b6a9 Stefan Roesch 2021-12-03 818 ret = kstrtoul(buf, 10, &val);
6e115adef2b6a9 Stefan Roesch 2021-12-03 819 if (ret)
6e115adef2b6a9 Stefan Roesch 2021-12-03 820 return ret;
6e115adef2b6a9 Stefan Roesch 2021-12-03 821
6e115adef2b6a9 Stefan Roesch 2021-12-03 822 if (val == 0)
6e115adef2b6a9 Stefan Roesch 2021-12-03 823 return -EINVAL;
6e115adef2b6a9 Stefan Roesch 2021-12-03 824
6e115adef2b6a9 Stefan Roesch 2021-12-03 825 /*
6e115adef2b6a9 Stefan Roesch 2021-12-03 826 * Allocate new chunk.
6e115adef2b6a9 Stefan Roesch 2021-12-03 827 */
6e115adef2b6a9 Stefan Roesch 2021-12-03 828 trans = btrfs_start_transaction(fs_info->tree_root, 0);
6e115adef2b6a9 Stefan Roesch 2021-12-03 829 if (!trans)
6e115adef2b6a9 Stefan Roesch 2021-12-03 @830 return PTR_ERR(trans);
PTR(NULL) is success.
6e115adef2b6a9 Stefan Roesch 2021-12-03 831 ret = btrfs_force_chunk_alloc(trans, space_info->flags);
6e115adef2b6a9 Stefan Roesch 2021-12-03 832 btrfs_end_transaction(trans);
6e115adef2b6a9 Stefan Roesch 2021-12-03 833
6e115adef2b6a9 Stefan Roesch 2021-12-03 834 if (ret == 1)
6e115adef2b6a9 Stefan Roesch 2021-12-03 835 return len;
6e115adef2b6a9 Stefan Roesch 2021-12-03 836
6e115adef2b6a9 Stefan Roesch 2021-12-03 837 return -ENOSPC;
6e115adef2b6a9 Stefan Roesch 2021-12-03 838 }
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [kdave-btrfs-devel:for-next-20220401 96/102] fs/btrfs/sysfs.c:830 btrfs_force_chunk_alloc_store() warn: passing zero to 'PTR_ERR'
2022-04-04 13:40 [kdave-btrfs-devel:for-next-20220401 96/102] fs/btrfs/sysfs.c:830 btrfs_force_chunk_alloc_store() warn: passing zero to 'PTR_ERR' Dan Carpenter
@ 2022-04-04 14:25 ` David Sterba
0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2022-04-04 14:25 UTC (permalink / raw)
To: Dan Carpenter
Cc: kbuild, Stefan Roesch, lkp, kbuild-all, linux-kernel, David Sterba
On Mon, Apr 04, 2022 at 04:40:17PM +0300, Dan Carpenter wrote:
> tree: https://github.com/kdave/btrfs-devel.git for-next-20220401
> head: 0c593f04d2f520a720c5c618ba9fe0355d08bba8
> commit: 6e115adef2b6a9b9a7cc25414e1b8f4414e02044 [96/102] btrfs: add force_chunk_alloc sysfs entry to force allocation
> config: nios2-randconfig-m031-20220403 (https://download.01.org/0day-ci/archive/20220403/202204030841.qWK5rMDU-lkp@intel.com/config)
> compiler: nios2-linux-gcc (GCC) 11.2.0
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> New smatch warnings:
> fs/btrfs/sysfs.c:830 btrfs_force_chunk_alloc_store() warn: passing zero to 'PTR_ERR'
Thanks for the report, I've found more problems in the patches so there
will be another update, also fixing this problem.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-04-04 14:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-04 13:40 [kdave-btrfs-devel:for-next-20220401 96/102] fs/btrfs/sysfs.c:830 btrfs_force_chunk_alloc_store() warn: passing zero to 'PTR_ERR' Dan Carpenter
2022-04-04 14:25 ` David Sterba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).