]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
nvmet: fix uninitialized work for zero kato
authorzhenwei pi <pizhenwei@bytedance.com>
Thu, 15 Oct 2020 01:51:40 +0000 (09:51 +0800)
committerStefan Bader <stefan.bader@canonical.com>
Mon, 9 Nov 2020 13:49:07 +0000 (14:49 +0100)
BugLink: https://bugs.launchpad.net/bugs/1902115
[ Upstream commit 85bd23f3dc09a2ae9e56885420e52c54bf983713 ]

When connecting a controller with a zero kato value using the following
command line

   nvme connect -t tcp -n NQN -a ADDR -s PORT --keep-alive-tmo=0

the warning below can be reproduced:

WARNING: CPU: 1 PID: 241 at kernel/workqueue.c:1627 __queue_delayed_work+0x6d/0x90
with trace:
  mod_delayed_work_on+0x59/0x90
  nvmet_update_cc+0xee/0x100 [nvmet]
  nvmet_execute_prop_set+0x72/0x80 [nvmet]
  nvmet_tcp_try_recv_pdu+0x2f7/0x770 [nvmet_tcp]
  nvmet_tcp_io_work+0x63f/0xb2d [nvmet_tcp]
  ...

This is caused by queuing up an uninitialized work.  Althrough the
keep-alive timer is disabled during allocating the controller (fixed in
0d3b6a8d213a), ka_work still has a chance to run (called by
nvmet_start_ctrl).

Fixes: 0d3b6a8d213a ("nvmet: Disable keep-alive timer when kato is cleared to 0h")
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Ian May <ian.may@canonical.com>
drivers/nvme/target/core.c

index 7d7176369edf706dc2ecac8d3090d1e52bad0ffd..6b2f1e290fa7371c605854640c0b84f9b658f0ef 100644 (file)
@@ -1048,7 +1048,8 @@ static void nvmet_start_ctrl(struct nvmet_ctrl *ctrl)
         * in case a host died before it enabled the controller.  Hence, simply
         * reset the keep alive timer when the controller is enabled.
         */
-       mod_delayed_work(system_wq, &ctrl->ka_work, ctrl->kato * HZ);
+       if (ctrl->kato)
+               mod_delayed_work(system_wq, &ctrl->ka_work, ctrl->kato * HZ);
 }
 
 static void nvmet_clear_ctrl(struct nvmet_ctrl *ctrl)