Skip to contentSkip to conversation

drivers/nvme/host/core.c:1434 nvme_update_formats() error: we previously assumed 'ns->disk' could be null (see line 1432)

PATCH In review Dan Carpenter 2 participants 2 messages Jul 7, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 33/33 drivers/nvme/host/core.c:1434 nvme_update_formats() error: we previously assumed 'ns->disk' could be null (see line 1432)

tree:   git://git.infradead.org/nvme.git nvme-5.9
head:   b7ce8e511525050739e0a675355d2c9195fd7280
commit: b7ce8e511525050739e0a675355d2c9195fd7280 [33/33] nvme: support for zoned namespaces
config: x86_64-randconfig-m001-20200703 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-14) 9.3.0

If you fix the issue, kindly add following tag as appropriate

smatch warnings:
drivers/nvme/host/core.c:1434 nvme_update_formats() error: we previously assumed 'ns->disk' could be null (see line 1432)

git remote add linux-nvme git://git.infradead.org/nvme.git
git remote update linux-nvme
git checkout b7ce8e511525050739e0a675355d2c9195fd7280 vim +1434 drivers/nvme/host/core.c

b7ce8e51152505 Keith Busch 2020-06-29  1426  static void nvme_update_formats(struct nvme_ctrl *ctrl, u32 *effects)
84fef62d135b6e Keith Busch 2017-11-07  1427  {
cf39a6bc342b98 Scott Bauer 2018-06-29  1428  	struct nvme_ns *ns;
84fef62d135b6e Keith Busch 2017-11-07  1429  
cf39a6bc342b98 Scott Bauer 2018-06-29  1430  	down_read(&ctrl->namespaces_rwsem);
cf39a6bc342b98 Scott Bauer 2018-06-29  1431  	list_for_each_entry(ns, &ctrl->namespaces, list)
b7ce8e51152505 Keith Busch 2020-06-29 @1432  		if (ns->disk && _nvme_revalidate_disk(ns->disk))
                                                            ^^^^^^^^

Assume this is NULL

cf39a6bc342b98 Scott Bauer 2018-06-29 1433 nvme_set_queue_dying(ns);

b7ce8e51152505 Keith Busch 2020-06-29 @1434  		else if (blk_queue_is_zoned(ns->disk->queue)) {
                                                                                    ^^^^^^^^

it will Oops.

b7ce8e51152505 Keith Busch 2020-06-29  1435  			/*
b7ce8e51152505 Keith Busch 2020-06-29  1436  			 * IO commands are required to fully revalidate a zoned
b7ce8e51152505 Keith Busch 2020-06-29  1437  			 * device. Force the command effects to trigger rescan
b7ce8e51152505 Keith Busch 2020-06-29  1438  			 * work so report zones can run in a context with
b7ce8e51152505 Keith Busch 2020-06-29  1439  			 * unfrozen IO queues.
b7ce8e51152505 Keith Busch 2020-06-29  1440  			 */
b7ce8e51152505 Keith Busch 2020-06-29  1441  			*effects |= NVME_CMD_EFFECTS_NCC;
b7ce8e51152505 Keith Busch 2020-06-29  1442  		}
cf39a6bc342b98 Scott Bauer 2018-06-29  1443  	up_read(&ctrl->namespaces_rwsem);
84fef62d135b6e Keith Busch 2017-11-07  1444  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#1 lore raw

Hi Dan,

As far as I can tell ->disk is never NULL for namespaces that can be found through the namespaces list, so I think the fix is to just remove these checks.

Thanks for the headsup.