[PATCHv2 14/17] nvme: fix Clang context analysis warning in rdma.c
Nilay Shroff
nilay at linux.ibm.com
Fri Jun 26 08:31:20 PDT 2026
On 6/26/26 12:19 PM, Christoph Hellwig wrote:
> 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?
>
I tried using list_empty_careful() but clang still throws the
same warning. And yes it needs same annotation to suppress
the warning.
Thanks,
--Nilay
More information about the Linux-nvme
mailing list