All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: broadcom: bcm4908enet: Fix a double free in bcm4908_enet_dma_alloc
@ 2021-04-02 17:40 Lv Yunlong
  2021-04-06 23:20 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Lv Yunlong @ 2021-04-02 17:40 UTC (permalink / raw)
  To: rafal, bcm-kernel-feedback-list, davem, kuba
  Cc: netdev, linux-kernel, Lv Yunlong

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.

Fixes: 4feffeadbcb2e ("net: broadcom: bcm4908enet: add BCM4908 controller driver")
Signed-off-by: Lv Yunlong <lyl2019@mail.ustc.edu.cn>
---
 drivers/net/ethernet/broadcom/bcm4908_enet.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/broadcom/bcm4908_enet.c b/drivers/net/ethernet/broadcom/bcm4908_enet.c
index 0b70e9e0ddad..32058386e74b 100644
--- a/drivers/net/ethernet/broadcom/bcm4908_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm4908_enet.c
@@ -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;
 }
 
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net: broadcom: bcm4908enet: Fix a double free in bcm4908_enet_dma_alloc
  2021-04-02 17:40 [PATCH] net: broadcom: bcm4908enet: Fix a double free in bcm4908_enet_dma_alloc Lv Yunlong
@ 2021-04-06 23:20 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-04-06 23:20 UTC (permalink / raw)
  To: Lv Yunlong
  Cc: rafal, bcm-kernel-feedback-list, davem, kuba, netdev, linux-kernel

Hello:

This patch was applied to netdev/net.git (refs/heads/master):

On Fri,  2 Apr 2021 10:40:19 -0700 you wrote:
> 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.
> 
> [...]

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



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-04-06 23:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-02 17:40 [PATCH] net: broadcom: bcm4908enet: Fix a double free in bcm4908_enet_dma_alloc Lv Yunlong
2021-04-06 23:20 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.