All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: oe-kbuild@lists.linux.dev
Cc: lkp@intel.com, Dan Carpenter <error27@gmail.com>
Subject: drivers/block/nbd.c:1563 nbd_open() warn: passing a valid pointer to 'PTR_ERR'
Date: Mon, 20 Mar 2023 04:33:25 +0800	[thread overview]
Message-ID: <202303200401.f9MokspP-lkp@intel.com> (raw)

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Yu Kuai <yukuai3@huawei.com>
CC: Jens Axboe <axboe@kernel.dk>
CC: Hou Tao <houtao1@huawei.com>
CC: Josef Bacik <josef@toxicpanda.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   eaba52d63bfcf0047ce3a1bb011b35d4f066df8e
commit: c55b2b983b0fa012942c3eb16384b2b722caa810 nbd: fix race between nbd_alloc_config() and module removal
date:   10 months ago
:::::: branch date: 3 hours ago
:::::: commit date: 10 months ago
config: riscv-randconfig-m031-20230319 (https://download.01.org/0day-ci/archive/20230320/202303200401.f9MokspP-lkp@intel.com/config)
compiler: riscv32-linux-gcc (GCC) 12.1.0

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Link: https://lore.kernel.org/r/202303200401.f9MokspP-lkp@intel.com/

New smatch warnings:
drivers/block/nbd.c:1563 nbd_open() warn: passing a valid pointer to 'PTR_ERR'
drivers/block/nbd.c:1978 nbd_genl_connect() warn: passing a valid pointer to 'PTR_ERR'

Old smatch warnings:
arch/riscv/include/asm/atomic.h:204 arch_atomic_fetch_add_unless() warn: inconsistent indenting

vim +/PTR_ERR +1563 drivers/block/nbd.c

5ea8d10802ec4c Josef Bacik       2017-04-06  1537  
5ea8d10802ec4c Josef Bacik       2017-04-06  1538  static int nbd_open(struct block_device *bdev, fmode_t mode)
5ea8d10802ec4c Josef Bacik       2017-04-06  1539  {
5ea8d10802ec4c Josef Bacik       2017-04-06  1540  	struct nbd_device *nbd;
5ea8d10802ec4c Josef Bacik       2017-04-06  1541  	int ret = 0;
5ea8d10802ec4c Josef Bacik       2017-04-06  1542  
5ea8d10802ec4c Josef Bacik       2017-04-06  1543  	mutex_lock(&nbd_index_mutex);
5ea8d10802ec4c Josef Bacik       2017-04-06  1544  	nbd = bdev->bd_disk->private_data;
5ea8d10802ec4c Josef Bacik       2017-04-06  1545  	if (!nbd) {
5ea8d10802ec4c Josef Bacik       2017-04-06  1546  		ret = -ENXIO;
5ea8d10802ec4c Josef Bacik       2017-04-06  1547  		goto out;
5ea8d10802ec4c Josef Bacik       2017-04-06  1548  	}
c6a4759ea0c9a7 Josef Bacik       2017-04-06  1549  	if (!refcount_inc_not_zero(&nbd->refs)) {
c6a4759ea0c9a7 Josef Bacik       2017-04-06  1550  		ret = -ENXIO;
c6a4759ea0c9a7 Josef Bacik       2017-04-06  1551  		goto out;
c6a4759ea0c9a7 Josef Bacik       2017-04-06  1552  	}
5ea8d10802ec4c Josef Bacik       2017-04-06  1553  	if (!refcount_inc_not_zero(&nbd->config_refs)) {
5ea8d10802ec4c Josef Bacik       2017-04-06  1554  		struct nbd_config *config;
5ea8d10802ec4c Josef Bacik       2017-04-06  1555  
5ea8d10802ec4c Josef Bacik       2017-04-06  1556  		mutex_lock(&nbd->config_lock);
5ea8d10802ec4c Josef Bacik       2017-04-06  1557  		if (refcount_inc_not_zero(&nbd->config_refs)) {
5ea8d10802ec4c Josef Bacik       2017-04-06  1558  			mutex_unlock(&nbd->config_lock);
5ea8d10802ec4c Josef Bacik       2017-04-06  1559  			goto out;
5ea8d10802ec4c Josef Bacik       2017-04-06  1560  		}
c55b2b983b0fa0 Yu Kuai           2022-05-21  1561  		config = nbd_alloc_config();
c55b2b983b0fa0 Yu Kuai           2022-05-21  1562  		if (IS_ERR(config)) {
c55b2b983b0fa0 Yu Kuai           2022-05-21 @1563  			ret = PTR_ERR(config);
5ea8d10802ec4c Josef Bacik       2017-04-06  1564  			mutex_unlock(&nbd->config_lock);
5ea8d10802ec4c Josef Bacik       2017-04-06  1565  			goto out;
5ea8d10802ec4c Josef Bacik       2017-04-06  1566  		}
c55b2b983b0fa0 Yu Kuai           2022-05-21  1567  		nbd->config = config;
5ea8d10802ec4c Josef Bacik       2017-04-06  1568  		refcount_set(&nbd->config_refs, 1);
c6a4759ea0c9a7 Josef Bacik       2017-04-06  1569  		refcount_inc(&nbd->refs);
5ea8d10802ec4c Josef Bacik       2017-04-06  1570  		mutex_unlock(&nbd->config_lock);
1aba169e770911 Josh Triplett     2020-12-17  1571  		if (max_part)
38430f0876fa8b Christoph Hellwig 2020-09-21  1572  			set_bit(GD_NEED_PART_SCAN, &bdev->bd_disk->state);
fe1f9e6659ca61 Josef Bacik       2018-05-16  1573  	} else if (nbd_disconnected(nbd->config)) {
1aba169e770911 Josh Triplett     2020-12-17  1574  		if (max_part)
38430f0876fa8b Christoph Hellwig 2020-09-21  1575  			set_bit(GD_NEED_PART_SCAN, &bdev->bd_disk->state);
5ea8d10802ec4c Josef Bacik       2017-04-06  1576  	}
5ea8d10802ec4c Josef Bacik       2017-04-06  1577  out:
5ea8d10802ec4c Josef Bacik       2017-04-06  1578  	mutex_unlock(&nbd_index_mutex);
5ea8d10802ec4c Josef Bacik       2017-04-06  1579  	return ret;
5ea8d10802ec4c Josef Bacik       2017-04-06  1580  }
5ea8d10802ec4c Josef Bacik       2017-04-06  1581  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

                 reply	other threads:[~2023-03-19 20:34 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=202303200401.f9MokspP-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=error27@gmail.com \
    --cc=oe-kbuild@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.