diff mbox series

[net-next] RDMA/device: Change dev_hold() to netdev_hold() in ib_device_get_netdev()

Message ID 20250314085451.1551714-1-xuanqiang.luo@linux.dev (mailing list archive)
State New
Headers show
Series [net-next] RDMA/device: Change dev_hold() to netdev_hold() in ib_device_get_netdev() | expand

Commit Message

luoxuanqiang March 14, 2025, 8:54 a.m. UTC
From: luoxuanqiang <luoxuanqiang@kylinos.cn>

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()")
Signed-off-by: luoxuanqiang <luoxuanqiang@kylinos.cn>
---
 drivers/infiniband/core/device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

luoxuanqiang March 14, 2025, 9:07 a.m. UTC | #1
Please ignore the previous email. I overlooked some logic. Sorry for the 
disturbance.

在 2025/3/14 16:54, luoxuanqiang 写道:
> From: luoxuanqiang <luoxuanqiang@kylinos.cn>
>
> 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()")
> Signed-off-by: luoxuanqiang <luoxuanqiang@kylinos.cn>
> ---
>   drivers/infiniband/core/device.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
> index 0ded91f056f3..f65a7e2b4f2b 100644
> --- a/drivers/infiniband/core/device.c
> +++ b/drivers/infiniband/core/device.c
> @@ -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);
>   	}
>
diff mbox series

Patch

diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index 0ded91f056f3..f65a7e2b4f2b 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -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);
 	}