net: ethernet: arp: Fix incorrect adding to the pending queue

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 <raitraak@gmail.com>
This commit is contained in:
Rait Rääk 2024-12-05 07:52:48 +11:00 committed by Benjamin Cabé
commit 220c4fffd3

View file

@ -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);