Re: [PATCH net] net/smc: fix netdev refcnt leak in smc_ib_find_route()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


On 06.05.24 03:54, Wen Gu wrote:
A netdev refcnt leak issue was found when unregistering netdev after
using SMC. It can be reproduced as follows.

- run tests based on SMC.
- unregister the net device.

The following error message can be observed.

'unregister_netdevice: waiting for ethx to become free. Usage count = x'

With CONFIG_NET_DEV_REFCNT_TRACKER set, more detailed error message can
be provided by refcount tracker:

  unregister_netdevice: waiting for eth1 to become free. Usage count = 2
  ref_tracker: eth%d@ffff9cabc3bf8548 has 1/1 users at
       mlx5e_napi_poll+0x161/0x5e0 [mlx5_core]

It is because in smc_ib_find_route(), neigh_lookup() takes a netdev
refcnt but does not release. So fix it.

Fixes: e5c4744cfb59 ("net/smc: add SMC-Rv2 connection establishment")
Signed-off-by: Wen Gu <guwen@xxxxxxxxxxxxxxxxx>
  net/smc/smc_ib.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/smc/smc_ib.c b/net/smc/smc_ib.c
index 97704a9e84c7..b431bd8a5172 100644
--- a/net/smc/smc_ib.c
+++ b/net/smc/smc_ib.c
@@ -210,10 +210,11 @@ int smc_ib_find_route(struct net *net, __be32 saddr, __be32 daddr,
  		goto out;
  	if (rt->rt_uses_gateway && rt->rt_gw_family != AF_INET)
  		goto out;
-	neigh = rt->dst.ops->neigh_lookup(&rt->dst, NULL, &fl4.daddr);
+	neigh = dst_neigh_lookup(&rt->dst, &fl4.daddr);
  	if (neigh) {
  		memcpy(nexthop_mac, neigh->ha, ETH_ALEN);
  		*uses_gateway = rt->rt_uses_gateway;
+		neigh_release(neigh);
  		return 0;

Hi Wen,

Thanks for fixing that! It looks good to me and works well.
Please release rt for that condition in the next version. (Thx, @Ratheesh!)


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Kernel Development]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Info]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Linux Media]     [Device Mapper]

  Powered by Linux