wireless: iwlwifi: Fix a double free in iwl_txq_dyn_alloc_dma
authorLv Yunlong <lyl2019@mail.ustc.edu.cn>
Sat, 3 Apr 2021 05:47:55 +0000 (22:47 -0700)
committerLuca Coelho <luciano.coelho@intel.com>
Tue, 7 Dec 2021 11:10:10 +0000 (13:10 +0200)
In iwl_txq_dyn_alloc_dma, txq->tfds is freed at first time by:
iwl_txq_alloc()->goto err_free_tfds->dma_free_coherent(). But
it forgot to set txq->tfds to NULL.

Then the txq->tfds is freed again in iwl_txq_dyn_alloc_dma by:
goto error->iwl_txq_gen2_free_memory()->dma_free_coherent().

My patch sets txq->tfds to NULL after the first free to avoid the
double free.

Fixes: 0cd1ad2d7fd41 ("iwlwifi: move all bus-independent TX functions to common code")
Signed-off-by: Lv Yunlong <lyl2019@mail.ustc.edu.cn>
Link: https://lore.kernel.org/r/20210403054755.4781-1-lyl2019@mail.ustc.edu.cn
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
drivers/net/wireless/intel/iwlwifi/queue/tx.c

index 451b06069350196e99518c5c8decf309d5cc804f..0f3526b0c5b00977b73e342b0e22df90a46b1a73 100644 (file)
@@ -1072,6 +1072,7 @@ int iwl_txq_alloc(struct iwl_trans *trans, struct iwl_txq *txq, int slots_num,
        return 0;
 err_free_tfds:
        dma_free_coherent(trans->dev, tfd_sz, txq->tfds, txq->dma_addr);
+       txq->tfds = NULL;
 error:
        if (txq->entries && cmd_queue)
                for (i = 0; i < slots_num; i++)