net: broadcom: bcm4908enet: Fix a double free in bcm4908_enet_dma_alloc
Subsystems (3)
PATCH 1/1 net: broadcom: bcm4908enet: Fix a double free in bcm4908_enet_dma_alloc
In bcm4908_enet_dma_alloc, if callee bcm4908_dma_alloc_buf_descs() failed, it will free the ring->cpu_addr by dma_free_coherent() and return error. Then bcm4908_enet_dma_free() will be called, and free the same cpu_addr by dma_free_coherent() again.
My patch set ring->cpu_addr to NULL after it is freed in bcm4908_dma_alloc_buf_descs() to avoid the double free.
--- drivers/net/ethernet/broadcom/bcm4908_enet.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/broadcom/bcm4908_enet.c +1 -0
@@ -172,6 +172,7 @@ static int bcm4908_dma_alloc_buf_descs(struct bcm4908_enet *enet, err_free_buf_descs:dma_free_coherent (dev, size, ring->cpu_addr, ring->dma_addr); + ring->cpu_addr =NULL ;return -ENOMEM ; }
Signature · 1 line
2.25.1
This patch was applied to netdev/net.git (refs/heads/master):
Hello:
This patch was applied to netdev/net.git (refs/heads/master):
Quoted 9 lines · On Fri, 2 Apr 2021 10:40:19 -0700 you wrote:
In
bcm4908_enet_dma_alloc, if calleebcm4908_dma_alloc_buf_descs()failed, it will free thering->cpu_addrbydma_free_coherent()and return error. Thenbcm4908_enet_dma_free()will be called, and free the samecpu_addrbydma_free_coherent()again.My patch set
ring->cpu_addrto NULL after it is freed inbcm4908_dma_alloc_buf_descs()to avoid the double free.[...]
Here is the summary with links:
- net: broadcom: bcm4908enet: Fix a double free in bcm4908_enet_dma_alloc
https://git.kernel.org/netdev/net/c/b25b343db052
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html