Commit 5ea59db8 authored by Peter S. Housel's avatar Peter S. Housel Committed by Kalle Valo

brcmfmac: Fix glom_skb leak in brcmf_sdiod_recv_chain

An earlier change to this function (3bdae810) fixed a leak in the
case of an unsuccessful call to brcmf_sdiod_buffrw(). However, the
glom_skb buffer, used for emulating a scattering read, is never used
or referenced after its contents are copied into the destination
buffers, and therefore always needs to be freed by the end of the
function.

Fixes: 3bdae810 ("brcmfmac: Fix glob_skb leak in brcmf_sdiod_recv_chain")
Fixes: a413e39a ("brcmfmac: fix brcmf_sdcard_recv_chain() for host without sg support")
Cc: stable@vger.kernel.org # 4.9.x-
Signed-off-by: default avatarPeter S. Housel <housel@acm.org>
Signed-off-by: default avatarArend van Spriel <arend.vanspriel@broadcom.com>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent a9507d5c
...@@ -706,7 +706,7 @@ int brcmf_sdiod_recv_pkt(struct brcmf_sdio_dev *sdiodev, struct sk_buff *pkt) ...@@ -706,7 +706,7 @@ int brcmf_sdiod_recv_pkt(struct brcmf_sdio_dev *sdiodev, struct sk_buff *pkt)
int brcmf_sdiod_recv_chain(struct brcmf_sdio_dev *sdiodev, int brcmf_sdiod_recv_chain(struct brcmf_sdio_dev *sdiodev,
struct sk_buff_head *pktq, uint totlen) struct sk_buff_head *pktq, uint totlen)
{ {
struct sk_buff *glom_skb; struct sk_buff *glom_skb = NULL;
struct sk_buff *skb; struct sk_buff *skb;
u32 addr = sdiodev->sbwad; u32 addr = sdiodev->sbwad;
int err = 0; int err = 0;
...@@ -727,10 +727,8 @@ int brcmf_sdiod_recv_chain(struct brcmf_sdio_dev *sdiodev, ...@@ -727,10 +727,8 @@ int brcmf_sdiod_recv_chain(struct brcmf_sdio_dev *sdiodev,
return -ENOMEM; return -ENOMEM;
err = brcmf_sdiod_buffrw(sdiodev, SDIO_FUNC_2, false, addr, err = brcmf_sdiod_buffrw(sdiodev, SDIO_FUNC_2, false, addr,
glom_skb); glom_skb);
if (err) { if (err)
brcmu_pkt_buf_free_skb(glom_skb);
goto done; goto done;
}
skb_queue_walk(pktq, skb) { skb_queue_walk(pktq, skb) {
memcpy(skb->data, glom_skb->data, skb->len); memcpy(skb->data, glom_skb->data, skb->len);
...@@ -741,6 +739,7 @@ int brcmf_sdiod_recv_chain(struct brcmf_sdio_dev *sdiodev, ...@@ -741,6 +739,7 @@ int brcmf_sdiod_recv_chain(struct brcmf_sdio_dev *sdiodev,
pktq); pktq);
done: done:
brcmu_pkt_buf_free_skb(glom_skb);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment