]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 1 Dec 2025 10:43:29 +0000 (11:43 +0100)
[ Upstream commit 8d2a2a49c30f67a480fa9ed25e08436a446f057e ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/xfrm/xfrm_state.c

index 1e2f5ecd63248bf3607459d564694bab70bc7e8e..f8cb033f102edf8b00c3afdc582d63d4beb0ac81 100644 (file)
@@ -2117,14 +2117,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;