2022-12-04 06:35:45

by Zhang Changzhong

[permalink] [raw]
Subject: [PATCH net] ethernet: aeroflex: fix potential skb leak in greth_init_rings()

The greth_init_rings() function won't free the newly allocated skb when
dma_mapping_error() returns error, so add dev_kfree_skb() to fix it.

Compile tested only.

Fixes: d4c41139df6e ("net: Add Aeroflex Gaisler 10/100/1G Ethernet MAC driver")
Signed-off-by: Zhang Changzhong <[email protected]>
---
drivers/net/ethernet/aeroflex/greth.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/aeroflex/greth.c b/drivers/net/ethernet/aeroflex/greth.c
index e104fb0..aa0d2f3 100644
--- a/drivers/net/ethernet/aeroflex/greth.c
+++ b/drivers/net/ethernet/aeroflex/greth.c
@@ -258,6 +258,7 @@ static int greth_init_rings(struct greth_private *greth)
if (dma_mapping_error(greth->dev, dma_addr)) {
if (netif_msg_ifup(greth))
dev_err(greth->dev, "Could not create initial DMA mapping\n");
+ dev_kfree_skb(skb);
goto cleanup;
}
greth->rx_skbuff[i] = skb;
--
2.9.5


2022-12-05 07:44:41

by Leon Romanovsky

[permalink] [raw]
Subject: Re: [PATCH net] ethernet: aeroflex: fix potential skb leak in greth_init_rings()

On Sun, Dec 04, 2022 at 02:09:08PM +0800, Zhang Changzhong wrote:
> The greth_init_rings() function won't free the newly allocated skb when
> dma_mapping_error() returns error, so add dev_kfree_skb() to fix it.
>
> Compile tested only.
>
> Fixes: d4c41139df6e ("net: Add Aeroflex Gaisler 10/100/1G Ethernet MAC driver")
> Signed-off-by: Zhang Changzhong <[email protected]>
> ---
> drivers/net/ethernet/aeroflex/greth.c | 1 +
> 1 file changed, 1 insertion(+)
>

Thanks,
Reviewed-by: Leon Romanovsky <[email protected]>

2022-12-07 10:55:20

by patchwork-bot+netdevbpf

[permalink] [raw]
Subject: Re: [PATCH net] ethernet: aeroflex: fix potential skb leak in greth_init_rings()

Hello:

This patch was applied to netdev/net.git (master)
by Paolo Abeni <[email protected]>:

On Sun, 4 Dec 2022 14:09:08 +0800 you wrote:
> The greth_init_rings() function won't free the newly allocated skb when
> dma_mapping_error() returns error, so add dev_kfree_skb() to fix it.
>
> Compile tested only.
>
> Fixes: d4c41139df6e ("net: Add Aeroflex Gaisler 10/100/1G Ethernet MAC driver")
> Signed-off-by: Zhang Changzhong <[email protected]>
>
> [...]

Here is the summary with links:
- [net] ethernet: aeroflex: fix potential skb leak in greth_init_rings()
https://git.kernel.org/netdev/net/c/063a932b64db

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html