On Wed, Jul 10, 2024 at 01:33:10PM -0700, David Ahern wrote: > 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: 09f530f0c6d6 ("RDMA: Add netdevice_tracker to ib_device_set_netdev()") > Signed-off-by: David Ahern <dsahern@xxxxxxxxxx> > --- > v2 > - remove __dev_put now that netdev_put is used > > drivers/infiniband/core/device.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c > index 55aa7aa32d4a..9b99112baf47 100644 > --- a/drivers/infiniband/core/device.c > +++ b/drivers/infiniband/core/device.c > @@ -2167,14 +2167,13 @@ int ib_device_set_netdev(struct ib_device *ib_dev, struct net_device *ndev, > } > > if (old_ndev) > - netdev_tracker_free(ndev, &pdata->netdev_tracker); > + netdev_put(old_ndev, &pdata->netdev_tracker); > if (ndev) > netdev_hold(ndev, &pdata->netdev_tracker, GFP_ATOMIC); > rcu_assign_pointer(pdata->netdev, ndev); > spin_unlock_irqrestore(&pdata->netdev_lock, flags); > > add_ndev_hash(pdata); > - __dev_put(old_ndev); I applied with the following change: diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index 49a2ddaf5a38..1f867b7f7020 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -2184,14 +2184,12 @@ int ib_device_set_netdev(struct ib_device *ib_dev, struct net_device *ndev, return 0; } - if (old_ndev) - netdev_put(old_ndev, &pdata->netdev_tracker); - if (ndev) - netdev_hold(ndev, &pdata->netdev_tracker, GFP_ATOMIC); + netdev_hold(ndev, &pdata->netdev_tracker, GFP_ATOMIC); rcu_assign_pointer(pdata->netdev, ndev); spin_unlock_irqrestore(&pdata->netdev_lock, flags); add_ndev_hash(pdata); + netdev_put(old_ndev, &pdata->netdev_tracker); return 0; } > > return 0; > } > -- > 2.39.3 (Apple Git-146) > >