All of lore.kernel.org
 help / color / mirror / Atom feed
* drivers/nvme/host/core.c:2411:13: sparse: sparse: unsigned value that used to be signed checked against zero?
@ 2026-06-22 13:53 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2026-06-22 13:53 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp

:::::: 
:::::: Manual check reason: "low confidence static check warning: drivers/nvme/host/core.c:2411:13: sparse: sparse: unsigned value that used to be signed checked against zero?"
:::::: 

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Chao Shi <coshi036@gmail.com>
CC: Keith Busch <kbusch@kernel.org>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   ef0c9f75a19532d7675384708fc8621e10850104
commit: c8cdecdb47d3191146ab6a90b422d3271bc1ef89 nvme: core: reject invalid LBA data size from Identify Namespace
date:   5 weeks ago
:::::: branch date: 17 hours ago
:::::: commit date: 5 weeks ago
config: microblaze-randconfig-r122-20260618 (https://download.01.org/0day-ci/archive/20260622/202606222138.OKwmfFNN-lkp@intel.com/config)
compiler: microblaze-linux-gcc (GCC) 16.1.0
sparse: v0.6.5-rc1
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260622/202606222138.OKwmfFNN-lkp@intel.com/reproduce)

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
| Fixes: c8cdecdb47d3 ("nvme: core: reject invalid LBA data size from Identify Namespace")
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/r/202606222138.OKwmfFNN-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
>> drivers/nvme/host/core.c:2411:13: sparse: sparse: unsigned value that used to be signed checked against zero?
   drivers/nvme/host/core.c:2411:13: sparse: signed value source

vim +2411 drivers/nvme/host/core.c

30b5f20bb2ddab0 Keith Busch         2025-05-06  2366  
1a893c2bfef46ac Christoph Hellwig   2022-07-22  2367  static int nvme_update_ns_info_block(struct nvme_ns *ns,
1a893c2bfef46ac Christoph Hellwig   2022-07-22  2368  		struct nvme_ns_info *info)
ac81bfa9867103c Matias Bjørling     2016-09-16  2369  {
e6c9b130d681443 Christoph Hellwig   2024-03-04  2370  	struct queue_limits lim;
e5ea00a510c61e9 Christoph Hellwig   2024-03-04  2371  	struct nvme_id_ns_nvm *nvm = NULL;
c85c9ab926a592e Christoph Hellwig   2024-04-02  2372  	struct nvme_zone_info zi = {};
1a893c2bfef46ac Christoph Hellwig   2022-07-22  2373  	struct nvme_id_ns *id;
1e1a9cecfab3f22 Christoph Hellwig   2025-01-31  2374  	unsigned int memflags;
a5b1cd61820e88d Christoph Hellwig   2024-03-04  2375  	sector_t capacity;
1a893c2bfef46ac Christoph Hellwig   2022-07-22  2376  	unsigned lbaf;
240e6ee272c07a2 Keith Busch         2020-06-29  2377  	int ret;
1673f1f08c8876f Christoph Hellwig   2015-11-26  2378  
1a893c2bfef46ac Christoph Hellwig   2022-07-22  2379  	ret = nvme_identify_ns(ns->ctrl, info->nsid, &id);
1a893c2bfef46ac Christoph Hellwig   2022-07-22  2380  	if (ret)
1a893c2bfef46ac Christoph Hellwig   2022-07-22  2381  		return ret;
1a893c2bfef46ac Christoph Hellwig   2022-07-22  2382  
d8b90d600aff181 Ewan D. Milne       2023-11-27  2383  	if (id->ncap == 0) {
d8b90d600aff181 Ewan D. Milne       2023-11-27  2384  		/* namespace not allocated or attached */
d8b90d600aff181 Ewan D. Milne       2023-11-27  2385  		info->is_removed = true;
0551ec93a00d935 Christoph Hellwig   2024-04-03  2386  		ret = -ENXIO;
46e7422cda8482a Christoph Hellwig   2024-03-04  2387  		goto out;
d8b90d600aff181 Ewan D. Milne       2023-11-27  2388  	}
c85c9ab926a592e Christoph Hellwig   2024-04-02  2389  	lbaf = nvme_lbaf_index(id->flbas);
d8b90d600aff181 Ewan D. Milne       2023-11-27  2390  
823340b7e877b41 Caleb Sander Mateos 2026-02-27  2391  	if (nvme_id_cns_ok(ns->ctrl, NVME_ID_CNS_CS_NS)) {
e5ea00a510c61e9 Christoph Hellwig   2024-03-04  2392  		ret = nvme_identify_ns_nvm(ns->ctrl, info->nsid, &nvm);
e5ea00a510c61e9 Christoph Hellwig   2024-03-04  2393  		if (ret < 0)
e5ea00a510c61e9 Christoph Hellwig   2024-03-04  2394  			goto out;
d8b90d600aff181 Ewan D. Milne       2023-11-27  2395  	}
d8b90d600aff181 Ewan D. Milne       2023-11-27  2396  
c85c9ab926a592e Christoph Hellwig   2024-04-02  2397  	if (IS_ENABLED(CONFIG_BLK_DEV_ZONED) &&
c85c9ab926a592e Christoph Hellwig   2024-04-02  2398  	    ns->head->ids.csi == NVME_CSI_ZNS) {
c85c9ab926a592e Christoph Hellwig   2024-04-02  2399  		ret = nvme_query_zone_info(ns, lbaf, &zi);
c85c9ab926a592e Christoph Hellwig   2024-04-02  2400  		if (ret < 0)
c85c9ab926a592e Christoph Hellwig   2024-04-02  2401  			goto out;
c85c9ab926a592e Christoph Hellwig   2024-04-02  2402  	}
c85c9ab926a592e Christoph Hellwig   2024-04-02  2403  
30b5f20bb2ddab0 Keith Busch         2025-05-06  2404  	if (ns->ctrl->ctratt & NVME_CTRL_ATTR_FDPS) {
30b5f20bb2ddab0 Keith Busch         2025-05-06  2405  		ret = nvme_query_fdp_info(ns, info);
30b5f20bb2ddab0 Keith Busch         2025-05-06  2406  		if (ret < 0)
30b5f20bb2ddab0 Keith Busch         2025-05-06  2407  			goto out;
30b5f20bb2ddab0 Keith Busch         2025-05-06  2408  	}
30b5f20bb2ddab0 Keith Busch         2025-05-06  2409  
c8cdecdb47d3191 Chao Shi            2026-05-15  2410  	if (id->lbaf[lbaf].ds < SECTOR_SHIFT ||
c8cdecdb47d3191 Chao Shi            2026-05-15 @2411  	    check_shl_overflow(le64_to_cpu(id->nsze),
c8cdecdb47d3191 Chao Shi            2026-05-15  2412  			       id->lbaf[lbaf].ds - SECTOR_SHIFT,
c8cdecdb47d3191 Chao Shi            2026-05-15  2413  			       &capacity)) {
c8cdecdb47d3191 Chao Shi            2026-05-15  2414  		dev_warn_once(ns->ctrl->device,
c8cdecdb47d3191 Chao Shi            2026-05-15  2415  			"invalid LBA data size %u, skipping namespace\n",
c8cdecdb47d3191 Chao Shi            2026-05-15  2416  			id->lbaf[lbaf].ds);
c8cdecdb47d3191 Chao Shi            2026-05-15  2417  		ret = -ENODEV;
c8cdecdb47d3191 Chao Shi            2026-05-15  2418  		goto out;
c8cdecdb47d3191 Chao Shi            2026-05-15  2419  	}
c8cdecdb47d3191 Chao Shi            2026-05-15  2420  
473106dd3aa964a Christoph Hellwig   2025-01-10  2421  	lim = queue_limits_start_update(ns->disk->queue);
473106dd3aa964a Christoph Hellwig   2025-01-10  2422  
1e1a9cecfab3f22 Christoph Hellwig   2025-01-31  2423  	memflags = blk_mq_freeze_queue(ns->disk->queue);
9419e71b8d67312 Daniel Wagner       2023-12-18  2424  	ns->head->lba_shift = id->lbaf[lbaf].ds;
a1a825ab6a60380 Daniel Wagner       2023-12-18  2425  	ns->head->nuse = le64_to_cpu(id->nuse);
bc840b21a25a50f Keith Busch         2025-10-14  2426  	nvme_set_ctrl_limits(ns->ctrl, &lim, false);
6339b7edada2d0c Kanchan Joshi       2024-07-30  2427  	nvme_configure_metadata(ns->ctrl, ns->head, id, nvm, info);
e6c9b130d681443 Christoph Hellwig   2024-03-04  2428  	nvme_set_chunk_sectors(ns, id, &lim);
1029298da365598 Caleb Sander Mateos 2026-02-27  2429  	if (!nvme_update_disk_info(ns, id, nvm, &lim))
a5b1cd61820e88d Christoph Hellwig   2024-03-04  2430  		capacity = 0;
8695f060a02953b Alan Adamson        2025-05-08  2431  
e6c9b130d681443 Christoph Hellwig   2024-03-04  2432  	if (IS_ENABLED(CONFIG_BLK_DEV_ZONED) &&
c85c9ab926a592e Christoph Hellwig   2024-04-02  2433  	    ns->head->ids.csi == NVME_CSI_ZNS)
c85c9ab926a592e Christoph Hellwig   2024-04-02  2434  		nvme_update_zone_info(ns, &lim, &zi);
a5b1cd61820e88d Christoph Hellwig   2024-03-04  2435  
8a825d22a70915b Guixin Liu          2024-11-04  2436  	if ((ns->ctrl->vwc & NVME_CTRL_VWC_PRESENT) && !info->no_vwc)
1122c0c1cc71f74 Christoph Hellwig   2024-06-17  2437  		lim.features |= BLK_FEAT_WRITE_CACHE | BLK_FEAT_FUA;
1122c0c1cc71f74 Christoph Hellwig   2024-06-17  2438  	else
1122c0c1cc71f74 Christoph Hellwig   2024-06-17  2439  		lim.features &= ~(BLK_FEAT_WRITE_CACHE | BLK_FEAT_FUA);
a5b1cd61820e88d Christoph Hellwig   2024-03-04  2440  
1d811438851bae0 Wang Yugui          2024-10-10  2441  	if (info->is_rotational)
1d811438851bae0 Wang Yugui          2024-10-10  2442  		lim.features |= BLK_FEAT_ROTATIONAL;
1d811438851bae0 Wang Yugui          2024-10-10  2443  
a5b1cd61820e88d Christoph Hellwig   2024-03-04  2444  	/*
a5b1cd61820e88d Christoph Hellwig   2024-03-04  2445  	 * Register a metadata profile for PI, or the plain non-integrity NVMe
a5b1cd61820e88d Christoph Hellwig   2024-03-04  2446  	 * metadata masquerading as Type 0 if supported, otherwise reject block
a5b1cd61820e88d Christoph Hellwig   2024-03-04  2447  	 * I/O to namespaces with metadata except when the namespace supports
a5b1cd61820e88d Christoph Hellwig   2024-03-04  2448  	 * PI, as it can strip/insert in that case.
a5b1cd61820e88d Christoph Hellwig   2024-03-04  2449  	 */
6339b7edada2d0c Kanchan Joshi       2024-07-30  2450  	if (!nvme_init_integrity(ns->head, &lim, info))
a5b1cd61820e88d Christoph Hellwig   2024-03-04  2451  		capacity = 0;
a5b1cd61820e88d Christoph Hellwig   2024-03-04  2452  
30b5f20bb2ddab0 Keith Busch         2025-05-06  2453  	lim.max_write_streams = ns->head->nr_plids;
30b5f20bb2ddab0 Keith Busch         2025-05-06  2454  	if (lim.max_write_streams)
86b6e0bd1a69efd Caleb Sander Mateos 2025-05-06  2455  		lim.write_stream_granularity = min(info->runs, U32_MAX);
30b5f20bb2ddab0 Keith Busch         2025-05-06  2456  	else
30b5f20bb2ddab0 Keith Busch         2025-05-06  2457  		lim.write_stream_granularity = 0;
30b5f20bb2ddab0 Keith Busch         2025-05-06  2458  
1b96f862ecccb3e Christoph Hellwig   2022-10-30  2459  	/*
1b96f862ecccb3e Christoph Hellwig   2022-10-30  2460  	 * Only set the DEAC bit if the device guarantees that reads from
1b96f862ecccb3e Christoph Hellwig   2022-10-30  2461  	 * deallocated data return zeroes.  While the DEAC bit does not
1b96f862ecccb3e Christoph Hellwig   2022-10-30  2462  	 * require that, it must be a no-op if reads from deallocated data
1b96f862ecccb3e Christoph Hellwig   2022-10-30  2463  	 * do not return zeroes.
1b96f862ecccb3e Christoph Hellwig   2022-10-30  2464  	 */
545fb46e5bc6ffa Zhang Yi            2025-06-19  2465  	if ((id->dlfeat & 0x7) == 0x1 && (id->dlfeat & (1 << 3))) {
9419e71b8d67312 Daniel Wagner       2023-12-18  2466  		ns->head->features |= NVME_NS_DEAC;
545fb46e5bc6ffa Zhang Yi            2025-06-19  2467  		lim.max_hw_wzeroes_unmap_sectors = lim.max_write_zeroes_sectors;
545fb46e5bc6ffa Zhang Yi            2025-06-19  2468  	}
545fb46e5bc6ffa Zhang Yi            2025-06-19  2469  
545fb46e5bc6ffa Zhang Yi            2025-06-19  2470  	ret = queue_limits_commit_update(ns->disk->queue, &lim);
545fb46e5bc6ffa Zhang Yi            2025-06-19  2471  	if (ret) {
545fb46e5bc6ffa Zhang Yi            2025-06-19  2472  		blk_mq_unfreeze_queue(ns->disk->queue, memflags);
545fb46e5bc6ffa Zhang Yi            2025-06-19  2473  		goto out;
545fb46e5bc6ffa Zhang Yi            2025-06-19  2474  	}
545fb46e5bc6ffa Zhang Yi            2025-06-19  2475  
545fb46e5bc6ffa Zhang Yi            2025-06-19  2476  	set_capacity_and_notify(ns->disk, capacity);
1e4ea66af1db4fd Christoph Hellwig   2022-07-13  2477  	set_disk_ro(ns->disk, nvme_ns_is_readonly(ns, info));
e7d65803e2bb5bc Hannes Reinecke     2021-08-24  2478  	set_bit(NVME_NS_READY, &ns->flags);
1e1a9cecfab3f22 Christoph Hellwig   2025-01-31  2479  	blk_mq_unfreeze_queue(ns->disk->queue, memflags);
1673f1f08c8876f Christoph Hellwig   2015-11-26  2480  
3a9967ba7ace911 Christoph Hellwig   2020-09-28  2481  	if (blk_queue_is_zoned(ns->queue)) {
9b3c08b90fc212d Damien Le Moal      2024-04-08  2482  		ret = blk_revalidate_disk_zones(ns->disk);
8685699c28d7452 Keith Busch         2020-10-23  2483  		if (ret && !nvme_first_scan(ns->disk))
e06b425bc835ead Christoph Hellwig   2022-07-21  2484  			goto out;
b29f84857a0f1cb Max Gurtovoy        2020-05-19  2485  	}
b29f84857a0f1cb Max Gurtovoy        2020-05-19  2486  
e06b425bc835ead Christoph Hellwig   2022-07-21  2487  	ret = 0;
e06b425bc835ead Christoph Hellwig   2022-07-21  2488  out:
e5ea00a510c61e9 Christoph Hellwig   2024-03-04  2489  	kfree(nvm);
1a893c2bfef46ac Christoph Hellwig   2022-07-22  2490  	kfree(id);
240e6ee272c07a2 Keith Busch         2020-06-29  2491  	return ret;
240e6ee272c07a2 Keith Busch         2020-06-29  2492  }
240e6ee272c07a2 Keith Busch         2020-06-29  2493  

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-06-22 13:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-22 13:53 drivers/nvme/host/core.c:2411:13: sparse: sparse: unsigned value that used to be signed checked against zero? 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.