2021-04-02 18:27:16

by Lv Yunlong

[permalink] [raw]
Subject: [PATCH] wireless: marvell: mwl8k: Fix a double Free in mwl8k_probe_hw

In mwl8k_probe_hw, hw->priv->txq is freed at the first time by
dma_free_coherent() in the call chain:
if(!priv->ap_fw)->mwl8k_init_txqs(hw)->mwl8k_txq_init(hw, i).

Then in err_free_queues of mwl8k_probe_hw, hw->priv->txq is freed
at the second time by mwl8k_txq_deinit(hw, i)->dma_free_coherent().

My patch set txq->txd to NULL after the first free to avoid the
double free.

Fixes: a66098daacee2 ("mwl8k: Marvell TOPDOG wireless driver")
Signed-off-by: Lv Yunlong <[email protected]>
---
drivers/net/wireless/marvell/mwl8k.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/marvell/mwl8k.c b/drivers/net/wireless/marvell/mwl8k.c
index c9f8c056aa51..84b32a5f01ee 100644
--- a/drivers/net/wireless/marvell/mwl8k.c
+++ b/drivers/net/wireless/marvell/mwl8k.c
@@ -1473,6 +1473,7 @@ static int mwl8k_txq_init(struct ieee80211_hw *hw, int index)
if (txq->skb == NULL) {
dma_free_coherent(&priv->pdev->dev, size, txq->txd,
txq->txd_dma);
+ txq->txd = NULL;
return -ENOMEM;
}

--
2.25.1



2021-04-13 21:30:07

by Lv Yunlong

[permalink] [raw]
Subject: Re: [PATCH] wireless: marvell: mwl8k: Fix a double Free in mwl8k_probe_hw


Dear maintainers,

I'm sorry to disturb you, but this patch has not been reviewed for more than a week.
Could you please help to review this patch? It will not take you a lot time.

Sincerely.

> -----原始邮件-----
> 发件人: "Lv Yunlong" <[email protected]>
> 发送时间: 2021-04-03 02:26:27 (星期六)
> 收件人: [email protected], [email protected], [email protected], [email protected], [email protected]
> 抄送: [email protected], [email protected], [email protected], "Lv Yunlong" <[email protected]>
> 主题: [PATCH] wireless: marvell: mwl8k: Fix a double Free in mwl8k_probe_hw
>
> In mwl8k_probe_hw, hw->priv->txq is freed at the first time by
> dma_free_coherent() in the call chain:
> if(!priv->ap_fw)->mwl8k_init_txqs(hw)->mwl8k_txq_init(hw, i).
>
> Then in err_free_queues of mwl8k_probe_hw, hw->priv->txq is freed
> at the second time by mwl8k_txq_deinit(hw, i)->dma_free_coherent().
>
> My patch set txq->txd to NULL after the first free to avoid the
> double free.
>
> Fixes: a66098daacee2 ("mwl8k: Marvell TOPDOG wireless driver")
> Signed-off-by: Lv Yunlong <[email protected]>
> ---
> drivers/net/wireless/marvell/mwl8k.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/net/wireless/marvell/mwl8k.c b/drivers/net/wireless/marvell/mwl8k.c
> index c9f8c056aa51..84b32a5f01ee 100644
> --- a/drivers/net/wireless/marvell/mwl8k.c
> +++ b/drivers/net/wireless/marvell/mwl8k.c
> @@ -1473,6 +1473,7 @@ static int mwl8k_txq_init(struct ieee80211_hw *hw, int index)
> if (txq->skb == NULL) {
> dma_free_coherent(&priv->pdev->dev, size, txq->txd,
> txq->txd_dma);
> + txq->txd = NULL;
> return -ENOMEM;
> }
>
> --
> 2.25.1
>

2021-04-18 06:36:28

by Kalle Valo

[permalink] [raw]
Subject: Re: mwl8k: Fix a double Free in mwl8k_probe_hw

Lv Yunlong <[email protected]> wrote:

> In mwl8k_probe_hw, hw->priv->txq is freed at the first time by
> dma_free_coherent() in the call chain:
> if(!priv->ap_fw)->mwl8k_init_txqs(hw)->mwl8k_txq_init(hw, i).
>
> Then in err_free_queues of mwl8k_probe_hw, hw->priv->txq is freed
> at the second time by mwl8k_txq_deinit(hw, i)->dma_free_coherent().
>
> My patch set txq->txd to NULL after the first free to avoid the
> double free.
>
> Fixes: a66098daacee2 ("mwl8k: Marvell TOPDOG wireless driver")
> Signed-off-by: Lv Yunlong <[email protected]>

Patch applied to wireless-drivers-next.git, thanks.

a8e083ee8e2a mwl8k: Fix a double Free in mwl8k_probe_hw

--
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches