From e906dc2a33de221b4cb2b2b7ba2e03835f3ee40e Mon Sep 17 00:00:00 2001 From: Nilay Shroff Date: Mon, 13 Jul 2026 17:24:18 +0530 Subject: nvme: fix context analysis warning in rdma.c After adding Clang lock context annotations in rdma.c, Clang reports the following warning when context analysis is enabled: drivers/nvme/host/rdma.c:972:24: warning: passing pointer to variable 'list' requires holding mutex 'nvme_rdma_ctrl_mutex' [-Wthread-safety-pointer] 972 | if (list_empty(&ctrl->list)) | ^ The warning is triggered because ctrl->list is annotated as being protected by nvme_rdma_ctrl_mutex, but list_empty(&ctrl->list) is invoked without holding that mutex. Replace list_empty() with list_empty_careful(), which is intended for lockless inspection of list heads during teardown when no concurrent list modifications are expected. This suppresses the corresponding context analysis warning while preserving the existing behavior. Reviewed-by: Christoph Hellwig Signed-off-by: Nilay Shroff Signed-off-by: Keith Busch --- drivers/nvme/host/rdma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c index 9111d58f9871..01743ae01466 100644 --- a/drivers/nvme/host/rdma.c +++ b/drivers/nvme/host/rdma.c @@ -1000,7 +1000,7 @@ static void nvme_rdma_free_ctrl(struct nvme_ctrl *nctrl) { struct nvme_rdma_ctrl *ctrl = to_rdma_ctrl(nctrl); - if (list_empty(&ctrl->list)) + if (list_empty_careful(&ctrl->list)) goto free_ctrl; mutex_lock(&nvme_rdma_ctrl_mutex); -- cgit v1.2.3