mirror of
https://github.com/torvalds/linux.git
synced 2024-12-24 11:51:27 +00:00
RDMA: Fix netdev tracker in ib_device_set_netdev
If a netdev has already been assigned, ib_device_set_netdev needs to
release the reference on the older netdev but it is mistakenly being
called for the new netdev. Fix it and in the process use netdev_put
to be symmetrical with the netdev_hold.
Fixes: 09f530f0c6
("RDMA: Add netdevice_tracker to ib_device_set_netdev()")
Signed-off-by: David Ahern <dsahern@kernel.org>
Link: https://lore.kernel.org/r/20240710203310.19317-1-dsahern@kernel.org
Signed-off-by: Leon Romanovsky <leon@kernel.org>
This commit is contained in:
parent
bbddfa2255
commit
2043a14fb3
@ -2184,16 +2184,12 @@ int ib_device_set_netdev(struct ib_device *ib_dev, struct net_device *ndev,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (old_ndev)
|
||||
netdev_tracker_free(ndev, &pdata->netdev_tracker);
|
||||
if (ndev)
|
||||
netdev_hold(ndev, &pdata->netdev_tracker, GFP_ATOMIC);
|
||||
rcu_assign_pointer(pdata->netdev, ndev);
|
||||
netdev_put(old_ndev, &pdata->netdev_tracker);
|
||||
netdev_hold(ndev, &pdata->netdev_tracker, GFP_ATOMIC);
|
||||
spin_unlock_irqrestore(&pdata->netdev_lock, flags);
|
||||
|
||||
add_ndev_hash(pdata);
|
||||
__dev_put(old_ndev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(ib_device_set_netdev);
|
||||
|
Loading…
Reference in New Issue
Block a user