public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
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: [fdmanana:misc-next 36/71] fs/btrfs/sysfs.c:811 btrfs_force_chunk_alloc_store() warn: passing zero to 'PTR_ERR'
Date: Fri, 10 Jun 2022 09:27:56 +0300	[thread overview]
Message-ID: <202206101159.fXYW8bYv-lkp@intel.com> (raw)

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@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

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


                 reply	other threads:[~2022-06-10  6:28 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=202206101159.fXYW8bYv-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