]> git.baikalelectronics.ru Git - kernel.git/commit
net: ethernet: mtk_eth_soc: fix potential memory leak in mtk_rx_alloc()
authorZiyang Xuan <william.xuanziyang@huawei.com>
Sun, 20 Nov 2022 03:54:05 +0000 (11:54 +0800)
committerJakub Kicinski <kuba@kernel.org>
Wed, 23 Nov 2022 04:16:08 +0000 (20:16 -0800)
commitd7d09408ae7dc7ee097591a86edd1a54a1a30f7d
treef611e4cfb1c58df300ee3e12f8b092200d0b709f
parent3f0a36cc06fa529c72155f44a5796b87b30dfb59
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: 099465330d57 ("net: ethernet: mtk_eth_soc: rely on page_pool for single page buffers")
Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>
Acked-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Link: https://lore.kernel.org/r/20221120035405.1464341-1-william.xuanziyang@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mediatek/mtk_eth_soc.c