Skip to contentSkip to conversation

RDMA/device: Change dev_hold() to netdev_hold() in ib_device_get_netdev()

PATCH In review luoxuanqiang 2 participants 2 messages Mar 14, 2025 InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RDMA/device: Change dev_hold() to netdev_hold() in ib_device_get_netdev()

From: luoxuanqiang <[email protected]>

When adding the "netdevice ref tracker" mechanism to ib_port_data, the dev_hold() in ib_device_get_netdev() was missed, which may cause false alarms of ref leak. Replace dev_hold() with netdev_hold() to fix it.

Fixes 09f530f0c6d6 ("RDMA: Add netdevice_tracker to ib_device_set_netdev()")
---
 drivers/infiniband/core/device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/device.c +1 -1
index 0ded91f056f3..f65a7e2b4f2b 100644
@@ -2270,7 +2270,7 @@ struct net_device *ib_device_get_netdev(struct ib_device *ib_dev,
 		spin_lock(&pdata->netdev_lock);
 		res = rcu_dereference_protected(
 			pdata->netdev, lockdep_is_held(&pdata->netdev_lock));
-		dev_hold(res);
+		netdev_hold(res, &pdata->netdev_tracker, GFP_ATOMIC);
 		spin_unlock(&pdata->netdev_lock);
 	}
 
Signature · 1 line
2.27.0
#1 lore raw

Please ignore the previous email. I overlooked some logic. Sorry for the disturbance.

Quoted 25 lines · luoxuanqiang

From: luoxuanqiang <[email protected]>

When adding the "netdevice ref tracker" mechanism to ib_port_data, the dev_hold() in ib_device_get_netdev() was missed, which may cause false alarms of ref leak. Replace dev_hold() with netdev_hold() to fix it.

Fixes 09f530f0c6d6 ("RDMA: Add netdevice_tracker to ib_device_set_netdev()")
---
  drivers/infiniband/core/device.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/device.c +1 -1
index 0ded91f056f3..f65a7e2b4f2b 100644
@@ -2270,7 +2270,7 @@ struct net_device *ib_device_get_netdev(struct ib_device *ib_dev,
  		spin_lock(&pdata->netdev_lock);
  		res = rcu_dereference_protected(
  			pdata->netdev, lockdep_is_held(&pdata->netdev_lock));
-		dev_hold(res);
+		netdev_hold(res, &pdata->netdev_tracker, GFP_ATOMIC);
  		spin_unlock(&pdata->netdev_lock);
  	}