]> git.baikalelectronics.ru Git - kernel.git/commit
net: broadcom: bcm4908enet: Fix a double free in bcm4908_enet_dma_alloc
authorLv Yunlong <lyl2019@mail.ustc.edu.cn>
Fri, 2 Apr 2021 17:40:19 +0000 (10:40 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 6 Apr 2021 23:15:21 +0000 (16:15 -0700)
commitb25b343db0526669947a427e9a31bac91d29bb06
tree837512aec7bdcaf0c48bee264a43075c774afa8c
parent08c27f3322fec11950b8f1384aa0f3b11d028528
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: 4feffeadbcb2e ("net: broadcom: bcm4908enet: add BCM4908 controller driver")
Signed-off-by: Lv Yunlong <lyl2019@mail.ustc.edu.cn>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/bcm4908_enet.c