[PATCH v2 18/22] nvmet: fix PCI P2P parameters access using nvmet_subsys::lock

sashiko-bot at kernel.org sashiko-bot at kernel.org
Tue Nov 17 23:55:58 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 0c0ad9daba7f9b5b285f1b0f44cf7bc001282d91
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->p2p_dev and drops the old PCI
device reference via pci_dev_put() under ns->subsys->lock, reading
ns->p2p_dev in nvmet_ns_p2pmem_show() without holding ns->subsys->lock is
a concurrency bug introduced with P2P memory support. Should this include:

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

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261118073505.288910-1-nilay@linux.ibm.com?part=18



More information about the Linux-nvme mailing list