未验证 提交 5e730aa5 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!761 net: stmmac: fix potential double free of dma descriptor resources

Merge Pull Request from: @Hongchen_Zhang 
 
a double free problem in stmmac driver was triggered when doing mugen test,
After apply this patch the double free problem disappear. 
 
Link:https://gitee.com/openeuler/kernel/pulls/761 

Reviewed-by: Jialin Zhang <zhangjialin11@huawei.com> 
Reviewed-by: Guo Dongtai <guodongtai@kylinos.cn> 
Reviewed-by: Yue Haibing <yuehaibing@huawei.com> 
Signed-off-by: Jialin Zhang <zhangjialin11@huawei.com> 
...@@ -1635,10 +1635,15 @@ static void free_dma_rx_desc_resources(struct stmmac_priv *priv) ...@@ -1635,10 +1635,15 @@ static void free_dma_rx_desc_resources(struct stmmac_priv *priv)
dma_free_coherent(priv->device, priv->dma_rx_size * dma_free_coherent(priv->device, priv->dma_rx_size *
sizeof(struct dma_extended_desc), sizeof(struct dma_extended_desc),
rx_q->dma_erx, rx_q->dma_rx_phy); rx_q->dma_erx, rx_q->dma_rx_phy);
rx_q->dma_rx = NULL;
rx_q->dma_erx = NULL;
kfree(rx_q->buf_pool); kfree(rx_q->buf_pool);
rx_q->buf_pool = NULL;
if (rx_q->page_pool) if (rx_q->page_pool)
page_pool_destroy(rx_q->page_pool); page_pool_destroy(rx_q->page_pool);
rx_q->page_pool = NULL;
} }
} }
...@@ -1675,8 +1680,15 @@ static void free_dma_tx_desc_resources(struct stmmac_priv *priv) ...@@ -1675,8 +1680,15 @@ static void free_dma_tx_desc_resources(struct stmmac_priv *priv)
dma_free_coherent(priv->device, size, addr, tx_q->dma_tx_phy); dma_free_coherent(priv->device, size, addr, tx_q->dma_tx_phy);
tx_q->dma_etx = NULL;
tx_q->dma_entx = NULL;
tx_q->dma_tx = NULL;
kfree(tx_q->tx_skbuff_dma); kfree(tx_q->tx_skbuff_dma);
tx_q->tx_skbuff_dma = NULL;
kfree(tx_q->tx_skbuff); kfree(tx_q->tx_skbuff);
tx_q->tx_skbuff = NULL;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册