Skip to content

Commit

Permalink
netpoll: allocate netdev tracker right away
Browse files Browse the repository at this point in the history
Commit 5fa5ae6 ("netpoll: add net device refcount tracker to struct netpoll")
was part of one of the initial netdev tracker introduction patches.
It added an explicit netdev_tracker_alloc() for netpoll, presumably
because the flow of the function is somewhat odd.
After most of the core networking stack was converted to use
the tracking hold() variants, netpoll's call to old dev_hold()
stands out a bit.

np is allocated by the caller and ready to use, we can use
netdev_hold() here, even tho np->ndev will only be set to
ndev inside __netpoll_setup().

Reviewed-by: Eric Dumazet <[email protected]>
Signed-off-by: Jakub Kicinski <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
kuba-moo authored and davem330 committed Jun 15, 2023
1 parent 70f7457 commit 48eed02
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions net/core/netpoll.c
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ int netpoll_setup(struct netpoll *np)
err = -ENODEV;
goto unlock;
}
dev_hold(ndev);
netdev_hold(ndev, &np->dev_tracker, GFP_KERNEL);

if (netdev_master_upper_dev_get(ndev)) {
np_err(np, "%s is a slave device, aborting\n", np->dev_name);
Expand Down Expand Up @@ -783,12 +783,11 @@ int netpoll_setup(struct netpoll *np)
err = __netpoll_setup(np, ndev);
if (err)
goto put;
netdev_tracker_alloc(ndev, &np->dev_tracker, GFP_KERNEL);
rtnl_unlock();
return 0;

put:
dev_put(ndev);
netdev_put(ndev, &np->dev_tracker);
unlock:
rtnl_unlock();
return err;
Expand Down

0 comments on commit 48eed02

Please sign in to comment.