]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
xfrm: fix netdev reference count imbalance
authorJianbo Liu <jianbol@nvidia.com>
Mon, 8 Jul 2024 06:58:11 +0000 (09:58 +0300)
committerSteffen Klassert <steffen.klassert@secunet.com>
Mon, 8 Jul 2024 11:24:13 +0000 (13:24 +0200)
In cited commit, netdev_tracker_alloc() is called for the newly
allocated xfrm state, but dev_hold() is missed, which causes netdev
reference count imbalance, because netdev_put() is called when the
state is freed in xfrm_dev_state_free(). Fix the issue by replacing
netdev_tracker_alloc() with netdev_hold().

Fixes: f8a70afafc17 ("xfrm: add TX datapath support for IPsec packet offload mode")
Signed-off-by: Jianbo Liu <jianbol@nvidia.com>
Reviewed-by: Cosmin Ratiu <cratiu@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
net/xfrm/xfrm_state.c

index 936f9348e5f63514def44e9aa07688725973a12b..67b2a399a48a73aa0725a716c926840cf31183ef 100644 (file)
@@ -1331,8 +1331,7 @@ found:
                        xso->dev = xdo->dev;
                        xso->real_dev = xdo->real_dev;
                        xso->flags = XFRM_DEV_OFFLOAD_FLAG_ACQ;
-                       netdev_tracker_alloc(xso->dev, &xso->dev_tracker,
-                                            GFP_ATOMIC);
+                       netdev_hold(xso->dev, &xso->dev_tracker, GFP_ATOMIC);
                        error = xso->dev->xfrmdev_ops->xdo_dev_state_add(x, NULL);
                        if (error) {
                                xso->dir = 0;