Browse Source

xfrm: fix error flow in case of add state fails

If add state fails in case of device offload, netdev refcount
will be negative since gc task is attempting to dev_free this state.
This is fixed by putting NULL in state dev field.

Signed-off-by: Aviad Yehezkel <aviadye@mellanox.com>
Signed-off-by: Boris Pismeny <borisp@mellanox.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Aviad Yehezkel 7 years ago
parent
commit
aa5dd6fa6f
1 changed files with 1 additions and 0 deletions
  1. 1 0
      net/xfrm/xfrm_device.c

+ 1 - 0
net/xfrm/xfrm_device.c

@@ -102,6 +102,7 @@ int xfrm_dev_state_add(struct net *net, struct xfrm_state *x,
 
 
 	err = dev->xfrmdev_ops->xdo_dev_state_add(x);
 	err = dev->xfrmdev_ops->xdo_dev_state_add(x);
 	if (err) {
 	if (err) {
+		xso->dev = NULL;
 		dev_put(dev);
 		dev_put(dev);
 		return err;
 		return err;
 	}
 	}