Skip to content
Commit 3213f808 authored by Ziyang Xuan's avatar Ziyang Xuan Committed by Jakub Kicinski
Browse files

net: ethernet: mtk_eth_soc: fix potential memory leak in mtk_rx_alloc()



When fail to dma_map_single() in mtk_rx_alloc(), it returns directly.
But the memory allocated for local variable data is not freed, and
local variabel data has not been attached to ring->data[i] yet, so the
memory allocated for local variable data will not be freed outside
mtk_rx_alloc() too. Thus memory leak would occur in this scenario.

Add skb_free_frag(data) when dma_map_single() failed.

Fixes: 23233e57 ("net: ethernet: mtk_eth_soc: rely on page_pool for single page buffers")
Signed-off-by: default avatarZiyang Xuan <william.xuanziyang@huawei.com>
Acked-by: default avatarLorenzo Bianconi <lorenzo.bianconi@redhat.com>
Link: https://lore.kernel.org/r/20221120035405.1464341-1-william.xuanziyang@huawei.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 0972457f
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment