* drivers/block/nbd.c:1563 nbd_open() warn: passing a valid pointer to 'PTR_ERR'
@ 2023-03-19 20:33 kernel test robot
0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2023-03-19 20:33 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Dan Carpenter
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-03-19 20:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-19 20:33 drivers/block/nbd.c:1563 nbd_open() warn: passing a valid pointer to 'PTR_ERR' kernel test robot
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.