Re: [PATCH rdma-next 1/1] RDMA/core: Fix socket leak in rdma_dev_init_net
From: Mark Bloch
Date: Tue Aug 12 2025 - 11:12:44 EST
On 12/08/2025 16:49, Parav Pandit wrote:
>
>
>> From: Håkon Bugge <haakon.bugge@xxxxxxxxxx>
>> Sent: 12 August 2025 07:08 PM
>>
>> If rdma_dev_init_net() has an early return because the supplied net is the
>> default init_net, we need to call rdma_nl_net_exit() before returning.
>>
> Not really.
> We still need to create the netlink socket so that rdma commands can be operational in init_net.
>
> However, there is a bug in incorrectly cleaning up the init_net during ib_core driver unload flow.
>
> I reviewed a fix internally from Mark Bloch for it.
> It should be posted anytime soon from Leon's queue.
>
> Mark,
> Can you please comment on plan to post the fix to rdma-rc?
Leon is reviewing it now, once he’s finished, he’ll send it.
Mark
>
>
>> Fixes: 4e0f7b907072 ("RDMA/core: Implement compat device/sysfs tree in net
>> namespace")
>> Cc: stable@xxxxxxxxxxxxxxx
>> Signed-off-by: Håkon Bugge <haakon.bugge@xxxxxxxxxx>
>> ---
>> drivers/infiniband/core/device.c | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
>> index 3145cb34a1d20..ec5642e70c5db 100644
>> --- a/drivers/infiniband/core/device.c
>> +++ b/drivers/infiniband/core/device.c
>> @@ -1203,8 +1203,10 @@ static __net_init int rdma_dev_init_net(struct net
>> *net)
>> return ret;
>>
>> /* No need to create any compat devices in default init_net. */
>> - if (net_eq(net, &init_net))
>> + if (net_eq(net, &init_net)) {
>> + rdma_nl_net_exit(rnet);
>> return 0;
>> + }
>>
>> ret = xa_alloc(&rdma_nets, &rnet->id, rnet, xa_limit_32b,
>> GFP_KERNEL);
>> if (ret) {
>> --
>> 2.43.5
>