[net] ethernet: aeroflex: fix potential skb leak in greth_init_rings()

Message ID 1670134149-29516-1-git-send-email-zhangchangzhong@huawei.com
State New
Headers
Series [net] ethernet: aeroflex: fix potential skb leak in greth_init_rings() |

Commit Message

Zhang Changzhong Dec. 4, 2022, 6:09 a.m. UTC
  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 <zhangchangzhong@huawei.com>
---
 drivers/net/ethernet/aeroflex/greth.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Leon Romanovsky Dec. 5, 2022, 7:16 a.m. UTC | #1
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 <zhangchangzhong@huawei.com>
> ---
>  drivers/net/ethernet/aeroflex/greth.c | 1 +
>  1 file changed, 1 insertion(+)
> 

Thanks,
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
  
patchwork-bot+netdevbpf@kernel.org Dec. 7, 2022, 10:50 a.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (master)
by Paolo Abeni <pabeni@redhat.com>:

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 <zhangchangzhong@huawei.com>
> 
> [...]

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!
  

Patch

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;