[PATCH] nvme-rdma: use current network namespace
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Wed Nov 25 06:25:58 PST 2026
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] nvme-rdma: netns reference leak in nvme_rdma_free_ctrl()
--
commit ea2302951454868193e26cecb0bf291eea317e73
Author: Hannes Reinecke <hare at kernel.org>
nvme-rdma: use current network namespace
This commit records the caller's network namespace in struct nvme_rdma_ctrl
and passes it to inet_pton_with_scope() and rdma_create_id() instead of
init_net.
> diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
> index 32189fdfc0f51..76b4cba80b369 100644
> --- a/drivers/nvme/host/rdma.c
> +++ b/drivers/nvme/host/rdma.c
[ ... ]
> @@ -2288,6 +2289,8 @@ static struct nvme_rdma_ctrl *nvme_rdma_alloc_ctrl(struct device *dev,
> if (!ctrl)
> return ERR_PTR(-ENOMEM);
> ctrl->ctrl.opts = opts;
> + ctrl->net = get_net(current->nsproxy->net_ns);
> +
> /*
> * Safe to init list while allocating ctrl object.
> */
[ ... ]
> @@ -2354,6 +2357,7 @@ static struct nvme_rdma_ctrl *nvme_rdma_alloc_ctrl(struct device *dev,
> out_kfree_queues:
> kfree(ctrl->queues);
> out_free_ctrl:
> + put_net(ctrl->net);
> kfree(ctrl);
> return ERR_PTR(ret);
> }
[Severity: High]
Does this leak ctrl->net when a controller is freed after
nvme_rdma_alloc_ctrl() succeeds? Once nvme_init_ctrl() succeeds,
controller teardown goes through nvme_put_ctrl() -> nvme_rdma_free_ctrl(),
which frees ctrl without calling put_net(ctrl->net), preventing the
network namespace from ever being destroyed.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261125141737.2383-1-hare@kernel.org?part=1
More information about the Linux-nvme
mailing list