Skip to content

Commit 4177e49

Browse files
Eric Dumazetkuba-moo
Eric Dumazet
authored andcommitted
xfrm: use net device refcount tracker helpers
xfrm4_fill_dst() and xfrm6_fill_dst() build dst, getting a device reference that will likely be released by standard dst_release() code. We have to track these references or risk a warning if CONFIG_NET_DEV_REFCNT_TRACKER=y Note to XFRM maintainers : Error path in xfrm6_fill_dst() releases the reference, but does not clear xdst->u.dst.dev, so I wonder if this could lead to double dev_put() in some cases, where a dst_release() _is_ called by the callers in their error path. This extra dev_put() was added in commit 84c4a9d ("xfrm6: release dev before returning error") Fixes: 9038c32 ("net: dst: add net device refcount tracking to dst_entry") Signed-off-by: Eric Dumazet <[email protected]> Cc: Cong Wang <[email protected]> Acked-by: Steffen Klassert <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 5092fb4 commit 4177e49

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

net/ipv4/xfrm4_policy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ static int xfrm4_fill_dst(struct xfrm_dst *xdst, struct net_device *dev,
7777
xdst->u.rt.rt_iif = fl4->flowi4_iif;
7878

7979
xdst->u.dst.dev = dev;
80-
dev_hold(dev);
80+
dev_hold_track(dev, &xdst->u.dst.dev_tracker, GFP_ATOMIC);
8181

8282
/* Sheit... I remember I did this right. Apparently,
8383
* it was magically lost, so this code needs audit */

net/ipv6/xfrm6_policy.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ static int xfrm6_fill_dst(struct xfrm_dst *xdst, struct net_device *dev,
7474
struct rt6_info *rt = (struct rt6_info *)xdst->route;
7575

7676
xdst->u.dst.dev = dev;
77-
dev_hold(dev);
77+
dev_hold_track(dev, &xdst->u.dst.dev_tracker, GFP_ATOMIC);
7878

7979
xdst->u.rt6.rt6i_idev = in6_dev_get(dev);
8080
if (!xdst->u.rt6.rt6i_idev) {
81-
dev_put(dev);
81+
dev_put_track(dev, &xdst->u.dst.dev_tracker);
8282
return -ENODEV;
8383
}
8484

0 commit comments

Comments
 (0)