From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796381290; b=pYA4ar3Y7hrveDSxE1WmVaV8BT7TfiI97rfglWMPpspxGaetwi6HT/yfqlPwaonJ+nn/ sCWaAKmVNGhwTHKTk5jQOvhu+u6Dkt0newM8m2UCK0N9hEPGN5JfOsKtMYMeC9OeWvtez 5SNAxO85oZNIskyf/Kk6gceW4QyCIcmgDwMo9trc/TSSNcQ0I2u0xZqHFSuoWcQZ80UEJ ZdUUAltRoV89arkongaVjjQiLlXyY2t9Z5LWZAyOKeVOe6KtcEqilzqTR8MRra1t97eLW JiLpTfR2QaXA+Gicvke7OLcPZ1p9S978oRdwpt1E2HIX0PDjSNt8g+6GZ0lk49Z5Zlg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381290; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=vSgEl/V3adurO81zlYuH0ra6QM7yKEJPpEG92X+m9iw=; b=l9WEvBeomdz1Ow5lV59PB80+nBZsIR523Q0kpEZb50Yr601Uyv1IrFsYENRWAILB/Q4T ++XFJjNDsoPi0BVejXMdfYQ7B/snGqsu3MgJ7A+C+MGJQnvjflimcf90/K38E79R0GOEA 6lNsXBex2lfhdcWZVKvWO7S+Rw/aq8KNIo/+yH+5vzqXiCDxPQB1yx+K7nUHhjHiAGI3T /k3zSKdK5MFHYc/GumLG0Nr7gDV0S8mjvjo0OalMM5sm2nPcenp0wJ3GQRRoaR888qQjn 8fWo7AvcEtMsMdXH1pRJ1pLwYYe9fFdXoQcxmJtUeJJwxTQKUuP3TJnwWTEI4iFXJ7w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=xpbEZ5sv; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E62C0606A330; Fri, 4 Dec 2026 10:48:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=xpbEZ5sv Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5B451F00934; Fri, 4 Dec 2026 10:48:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381289; bh=vSgEl/V3adurO81zlYuH0ra6QM7yKEJPpEG92X+m9iw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=xpbEZ5svD/gmuP2dvD6dZBB+3+aJHLGjLjOmqqB1s1Txb/WRgc+Cjs3GCYpvZuXcp //fffI5vsR1+N4yxseqL5YM3fL4P4OipXk1xli+VaN0jymVjrR1Ita+I6b67MjpNVU l1IJ/L+WP8nPFYbv4hvHYys6meMJxno0aMjDBejY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yaohan Li , Christoph Hellwig , Keith Busch Subject: [PATCH 7.3 640/742] nvme: stop asynchronous event work before ANA teardown Date: Fri, 4 Dec 2026 19:08:24 +0900 Message-ID: <20261204100652.092349647@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yaohan Li commit 9b657c565984f28976b1e471e3ce2f81cc269238 upstream. NVMe ANA work has several producers, including ANA AER completion, namespace scanning and failover processing. An AER completion can queue ana_work for an ANA notice and can separately queue async_event_work, which sends the AEN uevent and submits the next asynchronous event request. These work items access controller-owned state during asynchronous processing. This issue was investigated and the fix was developed with AI assistance (ZCode/GLM-4). Fixes: 0d0b660f214dc ("nvme: add ANA support") Cc: stable@vger.kernel.org Signed-off-by: Yaohan Li Reviewed-by: Christoph Hellwig Signed-off-by: Keith Busch Signed-off-by: Greg Kroah-Hartman --- drivers/nvme/host/core.c | 9 +++++++++ drivers/nvme/host/multipath.c | 7 +++++++ 2 files changed, 16 insertions(+) --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -5185,6 +5185,15 @@ EXPORT_SYMBOL_GPL(nvme_start_ctrl); void nvme_uninit_ctrl(struct nvme_ctrl *ctrl) { nvme_stop_keep_alive(ctrl); + + /* + * An AER completion can queue async_event_work; drain it before the + * controller's final release. Note that ana_work has additional + * producers (namespace scanning via nvme_scan_work, and the failover + * path in nvme_failover_req), which is why nvme_mpath_uninit() + * separately cancels ana_work after this point. + */ + cancel_work_sync(&ctrl->async_event_work); nvme_hwmon_exit(ctrl); nvme_fault_inject_fini(&ctrl->fault_inject); dev_pm_qos_hide_latency_tolerance(ctrl->device); --- a/drivers/nvme/host/multipath.c +++ b/drivers/nvme/host/multipath.c @@ -1491,6 +1491,13 @@ out_uninit: void nvme_mpath_uninit(struct nvme_ctrl *ctrl) { + /* + * ANA work can be queued by nvme_handle_aen_notice, nvme_scan_work, + * and nvme_failover_req. Drain remaining work before releasing the ANA + * resources. + */ + cancel_work_sync(&ctrl->ana_work); + kvfree(ctrl->ana_log_buf); ctrl->ana_log_buf = NULL; ctrl->ana_log_size = 0;