[PATCH] RDMA/core: skip compat cleanup for init_net
From: Jiale Yao
Date: Wed Oct 28 2026 - 01:04:21 EST
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@xxxxxxxxxxxxxxx
Signed-off-by: Jiale Yao <yaojiale02@xxxxxxx>
---
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