Skip to content

Commit a54a93d

Browse files
Ming Leikeithbusch
authored andcommitted
nvme: move stopping keep-alive into nvme_uninit_ctrl()
Commit 4733b65 ("nvme: start keep-alive after admin queue setup") moves starting keep-alive from nvme_start_ctrl() into nvme_init_ctrl_finish(), but don't move stopping keep-alive into nvme_uninit_ctrl(), so keep-alive work can be started and keep pending after failing to start controller, finally use-after-free is triggered if nvme host driver is unloaded. This patch fixes kernel panic when running nvme/004 in case that connection failure is triggered, by moving stopping keep-alive into nvme_uninit_ctrl(). This way is reasonable because keep-alive is now started in nvme_init_ctrl_finish(). Fixes: 3af755a ("nvme: move nvme_stop_keep_alive() back to original position") Cc: Hannes Reinecke <hare@suse.de> Cc: Mark O'Donovan <shiftee@posteo.net> Reported-by: Changhui Zhong <czhong@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: Keith Busch <kbusch@kernel.org>
1 parent 81475be commit a54a93d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/nvme/host/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4612,7 +4612,6 @@ void nvme_stop_ctrl(struct nvme_ctrl *ctrl)
46124612
{
46134613
nvme_mpath_stop(ctrl);
46144614
nvme_auth_stop(ctrl);
4615-
nvme_stop_keep_alive(ctrl);
46164615
nvme_stop_failfast_work(ctrl);
46174616
flush_work(&ctrl->async_event_work);
46184617
cancel_work_sync(&ctrl->fw_act_work);
@@ -4648,6 +4647,7 @@ EXPORT_SYMBOL_GPL(nvme_start_ctrl);
46484647

46494648
void nvme_uninit_ctrl(struct nvme_ctrl *ctrl)
46504649
{
4650+
nvme_stop_keep_alive(ctrl);
46514651
nvme_hwmon_exit(ctrl);
46524652
nvme_fault_inject_fini(&ctrl->fault_inject);
46534653
dev_pm_qos_hide_latency_tolerance(ctrl->device);

0 commit comments

Comments
 (0)