net: route: Fix pkt leak if net_send_data() fails

If the call to net_send_data() fails, for example if the forwading
interface is down, then the pkt will leak. The reference taken by
net_pkt_shallow_clone() will never be released. Fix the problem
by dropping the rerefence count in the error path.

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
This commit is contained in:
Andriy Gelman 2022-07-23 09:37:42 -04:00 committed by Carles Cufí
parent 88ba2fe3a9
commit a3cdb2102c

View file

@ -849,6 +849,7 @@ int net_route_mcast_forward_packet(struct net_pkt *pkt,
if (net_send_data(pkt_cpy) >= 0) {
++ret;
} else {
net_pkt_unref(pkt_cpy);
--err;
}
}