Re: [PATCH] nvmet: look up the P2P device under rcu_read_lock()
From: Christoph Hellwig
Date: Fri Nov 20 2026 - 12:44:08 EST
> static struct pci_dev *nvmet_req_find_p2p_dev(struct nvmet_req *req)
> {
> + struct pci_dev *p2p_dev;
> +
> if (!IS_ENABLED(CONFIG_PCI_P2PDMA) ||
> !req->sq->ctrl || !req->sq->qid || !req->ns)
> return NULL;
> - return radix_tree_lookup(&req->sq->ctrl->p2p_ns_map, req->ns->nsid);
> +
> + rcu_read_lock();
> + p2p_dev = radix_tree_lookup(&req->sq->ctrl->p2p_ns_map, req->ns->nsid);
> + rcu_read_unlock();
> +
> + return p2p_dev;
Not sure what the RCU section is supposed to protect here. If we
don't get a reference the result can be stale as soon as we're outside
the critical section. So IFF this is a real bug, it isn't fixed as
easily.