]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
xfrm: drop SA reference in xfrm_state_update if dir doesn't match
authorSabrina Dubroca <sd@queasysnail.net>
Thu, 16 Oct 2025 10:39:12 +0000 (12:39 +0200)
committerSteffen Klassert <steffen.klassert@secunet.com>
Tue, 21 Oct 2025 08:42:42 +0000 (10:42 +0200)
We're not updating x1, but we still need to put() it.

Fixes: a4a87fa4e96c ("xfrm: Add Direction to the SA in or out")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
net/xfrm/xfrm_state.c

index d213ca3653a8f20c9c5295f7c0c1e6b1f406dbe0..e4736d1ebb443355b0a6f6f0b71b847804dc92bb 100644 (file)
@@ -2191,14 +2191,18 @@ int xfrm_state_update(struct xfrm_state *x)
        }
 
        if (x1->km.state == XFRM_STATE_ACQ) {
-               if (x->dir && x1->dir != x->dir)
+               if (x->dir && x1->dir != x->dir) {
+                       to_put = x1;
                        goto out;
+               }
 
                __xfrm_state_insert(x);
                x = NULL;
        } else {
-               if (x1->dir != x->dir)
+               if (x1->dir != x->dir) {
+                       to_put = x1;
                        goto out;
+               }
        }
        err = 0;