[PATCH 20/23] nvmet: fix PCI P2P parameters access using nvmet_subsys::lock

sashiko-bot at kernel.org sashiko-bot at kernel.org
Mon Nov 9 14:12:15 PST 2026


Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] nvmet: missing Fixes trailer for nvmet_ns_p2pmem_show() lock fix
--

commit bf26a5b394d2fe3a4b6f9ef28cd2b4e1c3857ec6
Author: Nilay Shroff <nilay at linux.ibm.com>

> nvmet: fix PCI P2P parameters access using nvmet_subsys::lock
>
> The nvmet_ns::p2p_dev and nvmet_ns::use_p2pmem fields are protected by
> nvmet_subsys::lock. However, nvmet_ns_p2pmem_show() accesses these
> fields without holding the corresponding lock, triggering Clang context
> analyzer errors:
>
> drivers/nvme/target/configfs.c:587:42: error: reading variable 'p2p_dev' requires holding mutex 'to_nvmet_ns(item).subsys->lock'
>       [-Werror,-Wthread-safety-analysis]
>   587 |         return pci_p2pdma_enable_show(page, ns->p2p_dev, ns->use_p2pmem);
>       |                                                 ^
> drivers/nvme/target/configfs.c:587:55: error: reading variable 'use_p2pmem' requires holding mutex 'to_nvmet_ns(item).subsys->lock'
>       [-Werror,-Wthread-safety-analysis]
>   587 |         return pci_p2pdma_enable_show(page, ns->p2p_dev, ns->use_p2pmem);
>       |                                                              ^
>
> Fix the above errors by acquiring ns->subsys->lock before accessing
> PCI P2P parameters in nvmet_ns_p2pmem_show().
>
> Signed-off-by: Nilay Shroff <nilay at linux.ibm.com>

[Severity: Low]
Since nvmet_ns_p2pmem_store() updates ns->use_p2pmem and ns->p2p_dev and
calls pci_dev_put(ns->p2p_dev) under ns->subsys->lock, this fixes a real
unlocked access and concurrent show/store race in nvmet_ns_p2pmem_show().
Should this include:

  Fixes: c6925093d0b2 ("nvmet: Optionally use PCI P2P memory")

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261109033102.982191-25-nilay@linux.ibm.com?part=20



More information about the Linux-nvme mailing list