Commit b25b343d authored by Lv Yunlong's avatar Lv Yunlong Committed by David S. Miller

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.

Fixes: 4feffead ("net: broadcom: bcm4908enet: add BCM4908 controller driver")
Signed-off-by: default avatarLv Yunlong <lyl2019@mail.ustc.edu.cn>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 08c27f33
...@@ -172,6 +172,7 @@ static int bcm4908_dma_alloc_buf_descs(struct bcm4908_enet *enet, ...@@ -172,6 +172,7 @@ static int bcm4908_dma_alloc_buf_descs(struct bcm4908_enet *enet,
err_free_buf_descs: err_free_buf_descs:
dma_free_coherent(dev, size, ring->cpu_addr, ring->dma_addr); dma_free_coherent(dev, size, ring->cpu_addr, ring->dma_addr);
ring->cpu_addr = NULL;
return -ENOMEM; return -ENOMEM;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment