From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org, Stefan Roesch <shr@fb.com>
Cc: lkp@intel.com, kbuild-all@lists.01.org,
linux-kernel@vger.kernel.org, David Sterba <dsterba@suse.com>
Subject: [kdave-btrfs-devel:for-next-20220401 96/102] fs/btrfs/sysfs.c:830 btrfs_force_chunk_alloc_store() warn: passing zero to 'PTR_ERR'
Date: Mon, 4 Apr 2022 16:40:17 +0300 [thread overview]
Message-ID: <202204030841.qWK5rMDU-lkp@intel.com> (raw)
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
next reply other threads:[~2022-04-04 13:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-04 13:40 Dan Carpenter [this message]
2022-04-04 14:25 ` David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202204030841.qWK5rMDU-lkp@intel.com \
--to=dan.carpenter@oracle.com \
--cc=dsterba@suse.com \
--cc=kbuild-all@lists.01.org \
--cc=kbuild@lists.01.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=shr@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®