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=1796384064; b=VHfpo/omTjIIFjqWf22b4WKJ1urbZ4tBWa3y6F2ARPA9sGvbAQeeVJLzV82kRxPIHI6u 6cuKmPlqVgxceuhnFPbcO7YM2HDnVd+EZkZJKay/JrPTUA2O8zTYSlUZhuAsB3C7DIZF5 U7cq+o8zmFC/9rnBXXWF6TRvjwH2nJTYLzQzBvJDp+6D26f2gKk0DoSrwZP4oHscSuwkw WxDKblcGx86NVVjQ/HBSzEYL9u6ZSTF3ddG+ybdWYU9lzV2dER2iiOhoe0zQGWCEj5vAP 9TCbetX8PYawVLMeRge7kw0sAfDrJl/bWg6jZI0W/hcKE45xaAYIjI4elGLiUG9rKEw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384064; 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=XSEeM7npfMg3zfVM5j8+wz3tl4AHsOyktdPa1I5Zi6w=; b=qIg38EtS4pTzVmkBj7VfljFuaPnNBVI3+ve7BEljMZC9ksDMSnqt2N49NyKvZcgso64t jJuKz00+/qw7aB9+V0k783Z7xii6BqrMyIX/grLwGfmGTBHaAoEyFi4O6e+wlJdtRPy+d 53atfOavEiRRctfJYFRTNasWNh8mN6YD/vt78dJe3WVfTeG2Fgj8xtEbUmJEbAJjzQJ1s XkDO6vAgxRFa+BF+70ulaAnqVIbeKZyKhd5sjx+83Rb/uIszSlXLCIcw6kDqZlzOzmLqV rKIc9m1gtbGfgSib8WhPcvpITsMZuA/usESciQIi72pgwWwObvabVLkcNMxnrq8qrBQ== 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=Y5tMqhWW; 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 B34C9606A32D; Fri, 4 Dec 2026 11:34:24 +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=Y5tMqhWW Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29BC31F000C2; Fri, 4 Dec 2026 11:34:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384064; bh=XSEeM7npfMg3zfVM5j8+wz3tl4AHsOyktdPa1I5Zi6w=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Y5tMqhWWwHkh5kEVky3ouZNq7tIFNlo6WmGyuJViZVHsFT4ghI+R0QUaIFXdFHx5V 7q4FL8pSqAhkE5euu7Fi0p7a+A3EPZ0RUtmyETmBjZVkxJP3de3xsxVBKQlM25PDFB QgOR1dgJUgq3tA/4CWtlxTS6baV1wevXVWyCsF4g= 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.12 480/555] nvme: stop asynchronous event work before ANA teardown Date: Fri, 4 Dec 2026 19:08:43 +0900 Message-ID: <20261204100627.464874346@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@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.12-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 @@ -4815,6 +4815,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 @@ -1096,6 +1096,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;