[linux-nvme:nvme-7.2 2/7] drivers/nvme/host/core.c:5259 nvme_wait_freeze_timeout() warn: 'timeout' unsigned <= 0

Maurizio Lombardi mlombard at arkamax.eu
Thu May 21 00:47:33 PDT 2026


On Thu May 21, 2026 at 8:43 AM CEST, Dan Carpenter wrote:
> tree:   git://git.infradead.org/nvme.git nvme-7.2
> head:   00d7b33351aac0ea55d17167561e12bbeca73138
> commit: 23b6d2cbf75ff15647efbb7c0e5c03bd7ed1fe1a [2/7] nvme: remove redundant timeout argument from nvme_wait_freeze_timeout
> config: s390-randconfig-r073-20260521 (https://download.01.org/0day-ci/archive/20260521/202605211257.STzj2Ujv-lkp@intel.com/config)
> compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
> smatch: v0.5.0-9185-gbcc58b9c
>
> 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 <lkp at intel.com>
> | Reported-by: Dan Carpenter <error27 at gmail.com>
> | Closes: https://lore.kernel.org/r/202605211257.STzj2Ujv-lkp@intel.com/
>
> smatch warnings:
> drivers/nvme/host/core.c:5259 nvme_wait_freeze_timeout() warn: 'timeout' unsigned <= 0
>
> vim +/timeout +5259 drivers/nvme/host/core.c
>
> 23b6d2cbf75ff15 Maurizio Lombardi 2026-05-14  5249  int nvme_wait_freeze_timeout(struct nvme_ctrl *ctrl)
> 302ad8cc09339ea Keith Busch       2017-03-01  5250  {
> 23b6d2cbf75ff15 Maurizio Lombardi 2026-05-14  5251  	unsigned long timeout = NVME_IO_TIMEOUT;
>                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> This is unsigned.  NVME_IO_TIMEOUT is 30 * HZ.  Can the &ctrl->namespaces
> list ever be empty?

I already had a patch for this, I am going to submit it today.

https://lore.kernel.org/linux-nvme/4be04295-1b86-4dc3-abee-7d59c6c67ae9@flourine.local/

Thanks.

>
> 302ad8cc09339ea Keith Busch       2017-03-01  5252  	struct nvme_ns *ns;
> be647e2c76b27f4 Keith Busch       2024-05-21  5253  	int srcu_idx;
> 302ad8cc09339ea Keith Busch       2017-03-01  5254  
> be647e2c76b27f4 Keith Busch       2024-05-21  5255  	srcu_idx = srcu_read_lock(&ctrl->srcu);
> 6d1c69945ce63a9 Breno Leitao      2024-11-04  5256  	list_for_each_entry_srcu(ns, &ctrl->namespaces, list,
> 6d1c69945ce63a9 Breno Leitao      2024-11-04  5257  				 srcu_read_lock_held(&ctrl->srcu)) {
> 302ad8cc09339ea Keith Busch       2017-03-01  5258  		timeout = blk_mq_freeze_queue_wait_timeout(ns->queue, timeout);
> 302ad8cc09339ea Keith Busch       2017-03-01 @5259  		if (timeout <= 0)
>
> blk_mq_freeze_queue_wait_timeout() returns 0 on timeout and >= 1 on
> success.
>
> 302ad8cc09339ea Keith Busch       2017-03-01  5260  			break;
> 302ad8cc09339ea Keith Busch       2017-03-01  5261  	}
> be647e2c76b27f4 Keith Busch       2024-05-21  5262  	srcu_read_unlock(&ctrl->srcu, srcu_idx);
> 7cf0d7c0f3c3b02 Sagi Grimberg     2020-07-30  5263  	return timeout;
>
> This returns is nonsense.  ;)  >= 1 on success or empty.  0 on timeout.
>
> 302ad8cc09339ea Keith Busch       2017-03-01  5264  }
>
> --
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki




More information about the Linux-nvme mailing list