From 220c4fffd3db35a400c1807723416a336242e6e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rait=20R=C3=A4=C3=A4k?= Date: Thu, 5 Dec 2024 07:52:48 +1100 Subject: [PATCH] net: ethernet: arp: Fix incorrect adding to the pending queue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit k_fifo_put is a macro that expands the call to net_pkt_ref(pending) multiple times when CONFIG_TRACING is enabled thus causing extra reference for the pending packet and a memory leak. Fix by moving the referencing call to a separate line. Signed-off-by: Rait Rääk --- subsys/net/l2/ethernet/arp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/subsys/net/l2/ethernet/arp.c b/subsys/net/l2/ethernet/arp.c index 7d87f78e938..9ff51875795 100644 --- a/subsys/net/l2/ethernet/arp.c +++ b/subsys/net/l2/ethernet/arp.c @@ -291,7 +291,8 @@ static inline struct net_pkt *arp_prepare(struct net_if *iface, */ if (entry) { if (!net_pkt_ipv4_acd(pkt)) { - k_fifo_put(&entry->pending_queue, net_pkt_ref(pending)); + net_pkt_ref(pending); + k_fifo_put(&entry->pending_queue, pending); } entry->iface = net_pkt_iface(pkt);