[PATCHv2 14/17] nvme: fix Clang context analysis warning in rdma.c

Christoph Hellwig hch at lst.de
Thu Jun 25 23:49:16 PDT 2026


On Sun, Jun 14, 2026 at 06:45:29PM +0530, Nilay Shroff wrote:
> 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.

Does switching to list_empty_careful fix this?  If not, does
list_empty_careful need annotations to make this work?




More information about the Linux-nvme mailing list