brcmfmac: Fix use after free in brcmf_sdio_readframes()
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 3 Dec 2019 09:58:55 +0000 (12:58 +0300)
committerBen Hutchings <ben@decadent.org.uk>
Fri, 22 May 2020 20:19:18 +0000 (21:19 +0100)
commit 216b44000ada87a63891a8214c347e05a4aea8fe upstream.

The brcmu_pkt_buf_free_skb() function frees "pkt" so it leads to a
static checker warning:

    drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c:1974 brcmf_sdio_readframes()
    error: dereferencing freed memory 'pkt'

It looks like there was supposed to be a continue after we free "pkt".

Fixes: 4754fceeb9a6 ("brcmfmac: streamline SDIO read frame routine")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Franky Lin <franky.lin@broadcom.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
[bwh: Backported to 3.16: adjust filename]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c

index f93bdba6901c2543b69794e7d1df50295b2fb31b..1d58a745c211a54576e681275a5afc8da2380728 100644 (file)
@@ -1972,6 +1972,7 @@ static uint brcmf_sdio_readframes(struct brcmf_sdio *bus, uint maxframes)
                                               BRCMF_SDIO_FT_NORMAL)) {
                                rd->len = 0;
                                brcmu_pkt_buf_free_skb(pkt);
+                               continue;
                        }
                        bus->sdcnt.rx_readahead_cnt++;
                        if (rd->len != roundup(rd_new.len, 16)) {