Commit 99714e37 authored by Wang Hai's avatar Wang Hai Committed by Jakub Kicinski
Browse files

net: xilinx: axienet: fix potential memory leak in axienet_start_xmit()



The axienet_start_xmit() returns NETDEV_TX_OK without freeing skb
in case of dma_map_single() fails, add dev_kfree_skb_any() to fix it.

Fixes: 71791dc8 ("net: axienet: Check for DMA mapping errors")
Signed-off-by: default avatarWang Hai <wanghai38@huawei.com>
Reviewed-by: default avatarRadhey Shyam Pandey <radhey.shyam.pandey@amd.com>
Link: https://patch.msgid.link/20241014143704.31938-1-wanghai38@huawei.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 56f51dfd
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1051,6 +1051,7 @@ axienet_start_xmit(struct sk_buff *skb, struct net_device *ndev)
		if (net_ratelimit())
			netdev_err(ndev, "TX DMA mapping error\n");
		ndev->stats.tx_dropped++;
		dev_kfree_skb_any(skb);
		return NETDEV_TX_OK;
	}
	desc_set_phys_addr(lp, phys, cur_p);
@@ -1071,6 +1072,7 @@ axienet_start_xmit(struct sk_buff *skb, struct net_device *ndev)
			ndev->stats.tx_dropped++;
			axienet_free_tx_chain(lp, orig_tail_ptr, ii + 1,
					      true, NULL, 0);
			dev_kfree_skb_any(skb);
			return NETDEV_TX_OK;
		}
		desc_set_phys_addr(lp, phys, cur_p);