Patch "mwifiex: fix double free" has been added to the 4.19-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    mwifiex: fix double free

to the 4.19-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     mwifiex-fix-double-free.patch
and it can be found in the queue-4.19 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit a82c761ef59e2d5199c23d91eef99fd6e2e2b147
Author: Tom Rix <trix@xxxxxxxxxx>
Date:   Sun Oct 4 06:19:31 2020 -0700

    mwifiex: fix double free
    
    [ Upstream commit 53708f4fd9cfe389beab5c8daa763bcd0e0b4aef ]
    
    clang static analysis reports this problem:
    
    sdio.c:2403:3: warning: Attempt to free released memory
            kfree(card->mpa_rx.buf);
            ^~~~~~~~~~~~~~~~~~~~~~~
    
    When mwifiex_init_sdio() fails in its first call to
    mwifiex_alloc_sdio_mpa_buffer, it falls back to calling it
    again.  If the second alloc of mpa_tx.buf fails, the error
    handler will try to free the old, previously freed mpa_rx.buf.
    Reviewing the code, it looks like a second double free would
    happen with mwifiex_cleanup_sdio().
    
    So set both pointers to NULL when they are freed.
    
    Fixes: 5e6e3a92b9a4 ("wireless: mwifiex: initial commit for Marvell mwifiex driver")
    Signed-off-by: Tom Rix <trix@xxxxxxxxxx>
    Reviewed-by: Brian Norris <briannorris@xxxxxxxxxxxx>
    Signed-off-by: Kalle Valo <kvalo@xxxxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20201004131931.29782-1-trix@xxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/wireless/marvell/mwifiex/sdio.c b/drivers/net/wireless/marvell/mwifiex/sdio.c
index bfbe3aa058d93..0773d81072aa1 100644
--- a/drivers/net/wireless/marvell/mwifiex/sdio.c
+++ b/drivers/net/wireless/marvell/mwifiex/sdio.c
@@ -1985,6 +1985,8 @@ static int mwifiex_alloc_sdio_mpa_buffers(struct mwifiex_adapter *adapter,
 		kfree(card->mpa_rx.buf);
 		card->mpa_tx.buf_size = 0;
 		card->mpa_rx.buf_size = 0;
+		card->mpa_tx.buf = NULL;
+		card->mpa_rx.buf = NULL;
 	}
 
 	return ret;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux