From: Steffen Klassert Subject: [PATCH 2/4] xfrm: fix error flow in case of add state fails Date: Wed, 24 Jan 2018 10:47:11 +0100 Message-ID: <20180124094713.27913-3-steffen.klassert@secunet.com> References: <20180124094713.27913-1-steffen.klassert@secunet.com> Mime-Version: 1.0 Content-Type: text/plain Cc: Herbert Xu , Steffen Klassert , To: David Miller Return-path: Received: from a.mx.secunet.com ([62.96.220.36]:60908 "EHLO a.mx.secunet.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932887AbeAXJrU (ORCPT ); Wed, 24 Jan 2018 04:47:20 -0500 In-Reply-To: <20180124094713.27913-1-steffen.klassert@secunet.com> Sender: netdev-owner@vger.kernel.org List-ID: From: Aviad Yehezkel 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 Signed-off-by: Boris Pismeny Signed-off-by: Steffen Klassert --- net/xfrm/xfrm_device.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/xfrm/xfrm_device.c b/net/xfrm/xfrm_device.c index 30e5746085b8..ac9477189d1c 100644 --- a/net/xfrm/xfrm_device.c +++ b/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); if (err) { + xso->dev = NULL; dev_put(dev); return err; } -- 2.14.1