mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiale Yao <yaojiale02@163.com>
To: Jason Gunthorpe <jgg@ziepe.ca>, Leon Romanovsky <leon@kernel.org>,
	Parav Pandit <parav@mellanox.com>,
	linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH] RDMA/core: skip compat cleanup for init_net
Date: Wed, 28 Oct 2026 13:02:44 +0800	[thread overview]
Message-ID: <20261028050245.125370-1-yaojiale02@163.com> (raw)

rdma_dev_init_net() does not allocate an rdma_nets XArray entry or
create compatibility devices for init_net.  rdma_dev_exit_net() still
runs the common cleanup, using the zero-initialized rnet->id to hide and
erase an entry and removing compatibility devices with that ID.  ID zero
may belong to a non-default network namespace.

Handle init_net separately on exit, mirroring the initialization path.
Only tear down its netlink state and leave the XArray and compatibility
devices untouched.

Fixes: 1d2fedd8561d ("RDMA/core: Support netlink commands in non init_net net namespaces")
Cc: stable@vger.kernel.org
Signed-off-by: Jiale Yao <yaojiale02@163.com>
---
 drivers/infiniband/core/device.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index 29af9fe860e2..74460850ccba 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -1153,6 +1153,11 @@ static void rdma_dev_exit_net(struct net *net)
 	unsigned long index;
 	int ret;
 
+	if (net_eq(net, &init_net)) {
+		rdma_nl_net_exit(rnet);
+		return;
+	}
+
 	down_write(&rdma_nets_rwsem);
 	/*
 	 * Prevent the ID from being re-used and hide the id from xa_for_each.
-- 
2.34.1


             reply	other threads:[~2026-10-28  5:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-28  5:02 Jiale Yao [this message]
2026-11-03 11:53 ` Leon Romanovsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261028050245.125370-1-yaojiale02@163.com \
    --to=yaojiale02@163.com \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=parav@mellanox.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®