]> git.ipfire.org Git - thirdparty/linux.git/commit
net: openvswitch: fix possible kfree_skb of ERR_PTR
authorAdrian Moreno <amorenoz@redhat.com>
Thu, 4 Jun 2026 12:19:46 +0000 (14:19 +0200)
committerJakub Kicinski <kuba@kernel.org>
Tue, 9 Jun 2026 03:13:02 +0000 (20:13 -0700)
commitee30dd2909d8b98619f4341c70ec8dc8e155ab02
treeb85be7a21a6a37c9e7fe657b8422ec0da670a7bd
parentf0e42f0c4337b1f220de1ddd63f47197c7dee4de
net: openvswitch: fix possible kfree_skb of ERR_PTR

After the patch in the "Fixes" tag, the allocation of the "reply" skb
can happen either before or after locking the ovs_mutex.

However, error cleanups still follow the classical reversed order,
assuming "reply" is allocated before locking: it is freed after unlocking.

If "reply" allocation happens after locking the mutex and it fails,
"reply" is left with an ERR_PTR, and execution jumps to the correspondent
cleanup stage which will try to free an invalid pointer.

Fix this by setting the pointer to NULL after having saved its error
value.

Fixes: 893f139b9a6c ("openvswitch: Minimize ovs_flow_cmd_new|set critical sections.")
Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
Reviewed-by: Aaron Conole <aconole@redhat.com>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Link: https://patch.msgid.link/20260604121946.942164-1-amorenoz@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/openvswitch/datapath.c