Skip to contentSkip to conversation

drivers/nvme/host/qmap.c:208:8-12: ERROR: invalid reference to the index variable of the iterator on line 202 (fwd)

PATCH New Julia Lawall 1 participant 1 message Jan 7, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1347/1347 drivers/nvme/host/qmap.c:208:8-12: ERROR: invalid reference to the index variable of the iterator on line 202 (fwd)

Hello,

Is there a guarantee that the break on line 204 will be taken? If not, an invalid pointer will be returned. The NULL initialization of qmap is not useful. list_for_each_entry always initializes the first argument, even if the list is empty.

julia

---------- Forwarded message ----------
Date: Tue, 7 Jan 2025 12:11:28 +0800
From: kernel test robot <[email protected]>
To: [email protected]
Cc: [email protected], Julia Lawall <[email protected]>
Subject: [bytedance:5.15-velinux 1347/1347] drivers/nvme/host/qmap.c:208:8-12:
ERROR: invalid reference to the index variable of the iterator on line 202

BCC: [email protected]
CC: [email protected]
TO: [email protected]
TO: [email protected]
TO: [email protected]

tree:   https://github.com/bytedance/kernel.git 5.15-velinux
head:   272d9bd3d7e15bb1ad1efac12d9921350f961339
commit: 6e74a414cbefd3f08ab27d0e7ee5b56afa19a7f4 [1347/1347] bytedance: nvme-qmap: modify according advise

:::::: branch date: 19 hours ago
:::::: commit date: 19 hours ago
config: x86_64-randconfig-103-20250107 (https://download.01.org/0day-ci/archive/20250107/[email protected]/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags

| Reported-by: kernel test robot <[email protected]>
| Reported-by: Julia Lawall <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

cocci warnings: (new ones prefixed by >>)

Quoted 1 line
Quoted 1 line

drivers/nvme/host/qmap.c:208:8-12: ERROR: invalid reference to the index variable of the iterator on line 202

vim +208 drivers/nvme/host/qmap.c

3a9b973eb8419f dingtao.darren 2024-07-08  196
3a9b973eb8419f dingtao.darren 2024-07-08  197  struct nvme_qmap *nvme_qmap_get_qmap_from_ndev(struct nvme_dev *ndev)
3a9b973eb8419f dingtao.darren 2024-07-08  198  {
3a9b973eb8419f dingtao.darren 2024-07-08  199  	struct nvme_qmap *qmap = NULL;
3a9b973eb8419f dingtao.darren 2024-07-08  200
6e74a414cbefd3 dingtao.darren 2024-07-16  201  	down_read(&qmap_list.list_rwsem);
6e74a414cbefd3 dingtao.darren 2024-07-16 @202  	list_for_each_entry(qmap, &qmap_list.qmap_head, qmap_entry) {
3a9b973eb8419f dingtao.darren 2024-07-08  203  		if (qmap->nvme_dev == ndev)
6e74a414cbefd3 dingtao.darren 2024-07-16  204  			break;
3a9b973eb8419f dingtao.darren 2024-07-08  205  	}
6e74a414cbefd3 dingtao.darren 2024-07-16  206  	up_read(&qmap_list.list_rwsem);
6e74a414cbefd3 dingtao.darren 2024-07-16  207
6e74a414cbefd3 dingtao.darren 2024-07-16 @208  	return qmap;
3a9b973eb8419f dingtao.darren 2024-07-08  209  }
3a9b973eb8419f dingtao.darren 2024-07-08  210  EXPORT_SYMBOL_GPL(nvme_qmap_get_qmap_from_ndev);

3a9b973eb8419f dingtao.darren 2024-07-08 211

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki