323-v4.13-0002-brcmfmac-Fix-glom_skb-leak-in-brcmf_sdiod_recv_chain.patch 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. From 5ea59db8a375216e6c915c5586f556766673b5a7 Mon Sep 17 00:00:00 2001
  2. From: "Peter S. Housel" <housel@acm.org>
  3. Date: Mon, 12 Jun 2017 11:46:22 +0100
  4. Subject: [PATCH] brcmfmac: Fix glom_skb leak in brcmf_sdiod_recv_chain
  5. An earlier change to this function (3bdae810721b) fixed a leak in the
  6. case of an unsuccessful call to brcmf_sdiod_buffrw(). However, the
  7. glom_skb buffer, used for emulating a scattering read, is never used
  8. or referenced after its contents are copied into the destination
  9. buffers, and therefore always needs to be freed by the end of the
  10. function.
  11. Fixes: 3bdae810721b ("brcmfmac: Fix glob_skb leak in brcmf_sdiod_recv_chain")
  12. Fixes: a413e39a38573 ("brcmfmac: fix brcmf_sdcard_recv_chain() for host without sg support")
  13. Cc: stable@vger.kernel.org # 4.9.x-
  14. Signed-off-by: Peter S. Housel <housel@acm.org>
  15. Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
  16. Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  17. ---
  18. drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c | 7 +++----
  19. 1 file changed, 3 insertions(+), 4 deletions(-)
  20. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
  21. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
  22. @@ -705,7 +705,7 @@ done:
  23. int brcmf_sdiod_recv_chain(struct brcmf_sdio_dev *sdiodev,
  24. struct sk_buff_head *pktq, uint totlen)
  25. {
  26. - struct sk_buff *glom_skb;
  27. + struct sk_buff *glom_skb = NULL;
  28. struct sk_buff *skb;
  29. u32 addr = sdiodev->sbwad;
  30. int err = 0;
  31. @@ -726,10 +726,8 @@ int brcmf_sdiod_recv_chain(struct brcmf_
  32. return -ENOMEM;
  33. err = brcmf_sdiod_buffrw(sdiodev, SDIO_FUNC_2, false, addr,
  34. glom_skb);
  35. - if (err) {
  36. - brcmu_pkt_buf_free_skb(glom_skb);
  37. + if (err)
  38. goto done;
  39. - }
  40. skb_queue_walk(pktq, skb) {
  41. memcpy(skb->data, glom_skb->data, skb->len);
  42. @@ -740,6 +738,7 @@ int brcmf_sdiod_recv_chain(struct brcmf_
  43. pktq);
  44. done:
  45. + brcmu_pkt_buf_free_skb(glom_skb);
  46. return err;
  47. }