Skip to content

Commit f3ec2b5

Browse files
rleonklassert
authored andcommitted
xfrm: don't skip free of empty state in acquire policy
In destruction flow, the assignment of NULL to xso->dev caused to skip of xfrm_dev_state_free() call, which was called in xfrm_state_put(to_put) routine. Instead of open-coded variant of xfrm_dev_state_delete() and xfrm_dev_state_free(), let's use them directly. Fixes: f8a70af ("xfrm: add TX datapath support for IPsec packet offload mode") Signed-off-by: Leon Romanovsky <leonro@nvidia.com> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
1 parent 982c3ac commit f3ec2b5

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

include/net/xfrm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1984,6 +1984,7 @@ static inline void xfrm_dev_state_free(struct xfrm_state *x)
19841984
if (dev->xfrmdev_ops->xdo_dev_state_free)
19851985
dev->xfrmdev_ops->xdo_dev_state_free(x);
19861986
xso->dev = NULL;
1987+
xso->type = XFRM_DEV_OFFLOAD_UNSPECIFIED;
19871988
netdev_put(dev, &xso->dev_tracker);
19881989
}
19891990
}

net/xfrm/xfrm_state.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,12 +1324,8 @@ xfrm_state_find(const xfrm_address_t *daddr, const xfrm_address_t *saddr,
13241324
struct xfrm_dev_offload *xso = &x->xso;
13251325

13261326
if (xso->type == XFRM_DEV_OFFLOAD_PACKET) {
1327-
xso->dev->xfrmdev_ops->xdo_dev_state_delete(x);
1328-
xso->dir = 0;
1329-
netdev_put(xso->dev, &xso->dev_tracker);
1330-
xso->dev = NULL;
1331-
xso->real_dev = NULL;
1332-
xso->type = XFRM_DEV_OFFLOAD_UNSPECIFIED;
1327+
xfrm_dev_state_delete(x);
1328+
xfrm_dev_state_free(x);
13331329
}
13341330
#endif
13351331
x->km.state = XFRM_STATE_DEAD;

0 commit comments

Comments
 (0)