Skip to content

Commit 53708f4

Browse files
Tom RixKalle Valo
authored andcommitted
mwifiex: fix double free
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: 5e6e3a9 ("wireless: mwifiex: initial commit for Marvell mwifiex driver") Signed-off-by: Tom Rix <trix@redhat.com> Reviewed-by: Brian Norris <briannorris@chromium.org> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20201004131931.29782-1-trix@redhat.com
1 parent 8431350 commit 53708f4

File tree

1 file changed

+2
-0
lines changed
  • drivers/net/wireless/marvell/mwifiex

1 file changed

+2
-0
lines changed

drivers/net/wireless/marvell/mwifiex/sdio.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2403,6 +2403,8 @@ static int mwifiex_alloc_sdio_mpa_buffers(struct mwifiex_adapter *adapter,
24032403
kfree(card->mpa_rx.buf);
24042404
card->mpa_tx.buf_size = 0;
24052405
card->mpa_rx.buf_size = 0;
2406+
card->mpa_tx.buf = NULL;
2407+
card->mpa_rx.buf = NULL;
24062408
}
24072409

24082410
return ret;

0 commit comments

Comments
 (0)