Skip to content

Commit 03ff0d4

Browse files
talih0cfriedt
authored andcommitted
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 <[email protected]> (cherry picked from commit a3cdb21)
1 parent cd96136 commit 03ff0d4

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

subsys/net/ip/route.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,7 @@ int net_route_mcast_forward_packet(struct net_pkt *pkt,
691691
if (net_send_data(pkt_cpy) >= 0) {
692692
++ret;
693693
} else {
694+
net_pkt_unref(pkt_cpy);
694695
--err;
695696
}
696697
}

0 commit comments

Comments
 (0)