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=1796382696; b=fgnyU8CHU5XGf8hJKVhK1m54t/oCjwbxI47onWXoSKys/wmgxrRXctZinq/6iw5HTq3u BgwPn3PmwvO9hyCFHhqzAiKjDvcVvW3c3mD+xa04xpWnpExyOkeSX4NX3Jf/rjDTrMQGv Jf0K0qG59Kq6KYaHoAQKdcucanBlyBHjczb1p4i3Gibt7mZc7j3kEEAV+PDXtSBhLKdvo LN2e7wYJ1KzJjjYSl6SqC+b1gu1omR7D/n3wqVYIbabEKx+wMNTwuz9RHo+vzgoIclfqd plgib4ek51Stnn3z/pVQv9mP4z9KCPGaUrKVYPIIdanf5XntlpxoanH3Bt9mpRnm7pw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382696; 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=6ivhWSE0JTwLm106DLyafNOd2UyNXlkPUJZBupyfT2g=; b=Fdnk9AgqRLVgx70+qg4YN6VQd0ldJJdcLwwaHkzvjRUL9Rl8WaV3CGdqsQY7nHsd8dGK +/UEYF5aU9HIx37Y0aSSne01/+x+rER/or2Qj0Vrm2fsleGppctDBpL3R6rpDTN9kT3Wj Y5//XtRu2zAbcY7Y/Jo4AbvoW5PcbuHwaVBz3RNVYq/u3kllHqlk52hwXSH4B1cy3W33N dBS5Cwv7yo949CS4kuPHfgV9EgK6mPNUze9zzGWbgVHdqqTLUOpSMRxdMfejdLbORgtPY xzzWpj2thxiopbGsxJsXSQA1fPLr8mRmNs3LHGlUaIaxrj187lE5cNqJsoTcnCwwrnA== 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="1/qix+ps"; 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 DAF8D606A322; Fri, 4 Dec 2026 11:11:36 +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=1/qix+ps Received: by smtp.kernel.org (Postfix) with ESMTPSA id 512831F000C2; Fri, 4 Dec 2026 11:11:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382696; bh=6ivhWSE0JTwLm106DLyafNOd2UyNXlkPUJZBupyfT2g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=1/qix+ps4Nzy4T7JsXzd42pB9NVuKspm97YIr5D8ouWTuEZC5YL64tnL1ufvP0dN0 x42FtIt2sfO8hCYutY5xNhAWskGPHrQFBX/5roiqtXcs7UbziJTuTG3UXLA41R7NIS APkQYdzcAfHsj3Q8h7J+vFKBHJ0LqB5VResBeIGM= 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 6.18 565/703] nvme: stop asynchronous event work before ANA teardown Date: Fri, 4 Dec 2026 19:07:44 +0900 Message-ID: <20261204100642.801094733@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-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 @@ -5063,6 +5063,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 @@ -1406,6 +1406,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;