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, Filipe Manana <fdmanana@suse.com>,
David Sterba <dsterba@suse.com>
Subject: [fdmanana:dio_fixes 3/42] fs/btrfs/sysfs.c:811 btrfs_force_chunk_alloc_store() warn: passing zero to 'PTR_ERR'
Date: Tue, 12 Jul 2022 13:50:33 +0300 [thread overview]
Message-ID: <202207091909.wE5ZdB1d-lkp@intel.com> (raw)
tree: https://git.kernel.org/pub/scm/linux/kernel/git/fdmanana/linux.git dio_fixes
head: f01450d13f24e9a01436b60f5f2596ef650c790f
commit: fce393f3e59414984ba87693911080747b08ed09 [3/42] btrfs: sysfs: add force_chunk_alloc trigger to force allocation
config: riscv-randconfig-m031-20220709
compiler: riscv32-linux-gcc (GCC) 11.3.0
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.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
fce393f3e59414 Stefan Roesch 2022-02-08 782 static ssize_t btrfs_force_chunk_alloc_store(struct kobject *kobj,
fce393f3e59414 Stefan Roesch 2022-02-08 783 struct kobj_attribute *a,
fce393f3e59414 Stefan Roesch 2022-02-08 784 const char *buf, size_t len)
fce393f3e59414 Stefan Roesch 2022-02-08 785 {
fce393f3e59414 Stefan Roesch 2022-02-08 786 struct btrfs_space_info *space_info = to_space_info(kobj);
fce393f3e59414 Stefan Roesch 2022-02-08 787 struct btrfs_fs_info *fs_info = to_fs_info(get_btrfs_kobj(kobj));
fce393f3e59414 Stefan Roesch 2022-02-08 788 struct btrfs_trans_handle *trans;
fce393f3e59414 Stefan Roesch 2022-02-08 789 bool val;
fce393f3e59414 Stefan Roesch 2022-02-08 790 int ret;
fce393f3e59414 Stefan Roesch 2022-02-08 791
fce393f3e59414 Stefan Roesch 2022-02-08 792 if (!capable(CAP_SYS_ADMIN))
fce393f3e59414 Stefan Roesch 2022-02-08 793 return -EPERM;
fce393f3e59414 Stefan Roesch 2022-02-08 794
fce393f3e59414 Stefan Roesch 2022-02-08 795 if (sb_rdonly(fs_info->sb))
fce393f3e59414 Stefan Roesch 2022-02-08 796 return -EROFS;
fce393f3e59414 Stefan Roesch 2022-02-08 797
fce393f3e59414 Stefan Roesch 2022-02-08 798 ret = kstrtobool(buf, &val);
fce393f3e59414 Stefan Roesch 2022-02-08 799 if (ret)
fce393f3e59414 Stefan Roesch 2022-02-08 800 return ret;
fce393f3e59414 Stefan Roesch 2022-02-08 801
fce393f3e59414 Stefan Roesch 2022-02-08 802 if (!val)
fce393f3e59414 Stefan Roesch 2022-02-08 803 return -EINVAL;
fce393f3e59414 Stefan Roesch 2022-02-08 804
fce393f3e59414 Stefan Roesch 2022-02-08 805 /*
fce393f3e59414 Stefan Roesch 2022-02-08 806 * This is unsafe to be called from sysfs context and may cause
fce393f3e59414 Stefan Roesch 2022-02-08 807 * unexpected problems.
fce393f3e59414 Stefan Roesch 2022-02-08 808 */
fce393f3e59414 Stefan Roesch 2022-02-08 809 trans = btrfs_start_transaction(fs_info->tree_root, 0);
fce393f3e59414 Stefan Roesch 2022-02-08 810 if (!trans)
fce393f3e59414 Stefan Roesch 2022-02-08 @811 return PTR_ERR(trans);
This bug is already fixed upstread. Need to pull the NULL -> IS_ERR()
patch.
fce393f3e59414 Stefan Roesch 2022-02-08 812 ret = btrfs_force_chunk_alloc(trans, space_info->flags);
fce393f3e59414 Stefan Roesch 2022-02-08 813 btrfs_end_transaction(trans);
fce393f3e59414 Stefan Roesch 2022-02-08 814
fce393f3e59414 Stefan Roesch 2022-02-08 815 if (ret == 1)
fce393f3e59414 Stefan Roesch 2022-02-08 816 return len;
fce393f3e59414 Stefan Roesch 2022-02-08 817
fce393f3e59414 Stefan Roesch 2022-02-08 818 return -ENOSPC;
fce393f3e59414 Stefan Roesch 2022-02-08 819 }
reply other threads:[~2022-07-12 10:51 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=202207091909.wE5ZdB1d-lkp@intel.com \
--to=dan.carpenter@oracle.com \
--cc=dsterba@suse.com \
--cc=fdmanana@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