Commit 7d935143 authored by Wesley Atwell's avatar Wesley Atwell Committed by Jakub Kicinski
Browse files

netdevsim: drop PSP ext ref on forward failure



nsim_do_psp() takes an extra reference to the PSP skb extension so the
extension survives __dev_forward_skb(). That forward path scrubs the skb
and drops attached skb extensions before nsim_psp_handle_ext() can
reattach the PSP metadata.

If __dev_forward_skb() fails in nsim_forward_skb(), the function returns
before nsim_psp_handle_ext() can attach that extension to the skb, leaving
the extra reference leaked.

Drop the saved PSP extension reference before returning from the
forward-failure path. Guard the put because plain or non-decapsulated
traffic can also fail forwarding without ever taking the extra PSP
reference.

Fixes: f857478d ("netdevsim: a basic test PSP implementation")
Signed-off-by: default avatarWesley Atwell <atwellwea@gmail.com>
Reviewed-by: default avatarDaniel Zahka <daniel.zahka@gmail.com>
Link: https://patch.msgid.link/20260317061431.1482716-1-atwellwea@gmail.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 64dcbde7
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -109,8 +109,11 @@ static int nsim_forward_skb(struct net_device *tx_dev,
	int ret;

	ret = __dev_forward_skb(rx_dev, skb);
	if (ret)
	if (ret) {
		if (psp_ext)
			__skb_ext_put(psp_ext);
		return ret;
	}

	nsim_psp_handle_ext(skb, psp_ext);