318-v4.11-0001-brcmfmac-check-brcmf_bus_get_memdump-result-for-erro.patch 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
  2. Date: Mon, 30 Jan 2017 16:09:51 +0100
  3. Subject: [PATCH] brcmfmac: check brcmf_bus_get_memdump result for error
  4. MIME-Version: 1.0
  5. Content-Type: text/plain; charset=UTF-8
  6. Content-Transfer-Encoding: 8bit
  7. This method may be unsupported (see: USB bus) or may just fail (see:
  8. SDIO bus).
  9. While at it rework logic in brcmf_sdio_bus_get_memdump function to avoid
  10. too many conditional code nesting levels.
  11. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
  12. Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
  13. Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  14. ---
  15. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c
  16. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c
  17. @@ -32,16 +32,25 @@ static int brcmf_debug_create_memdump(st
  18. {
  19. void *dump;
  20. size_t ramsize;
  21. + int err;
  22. ramsize = brcmf_bus_get_ramsize(bus);
  23. - if (ramsize) {
  24. - dump = vzalloc(len + ramsize);
  25. - if (!dump)
  26. - return -ENOMEM;
  27. - memcpy(dump, data, len);
  28. - brcmf_bus_get_memdump(bus, dump + len, ramsize);
  29. - dev_coredumpv(bus->dev, dump, len + ramsize, GFP_KERNEL);
  30. + if (!ramsize)
  31. + return -ENOTSUPP;
  32. +
  33. + dump = vzalloc(len + ramsize);
  34. + if (!dump)
  35. + return -ENOMEM;
  36. +
  37. + memcpy(dump, data, len);
  38. + err = brcmf_bus_get_memdump(bus, dump + len, ramsize);
  39. + if (err) {
  40. + vfree(dump);
  41. + return err;
  42. }
  43. +
  44. + dev_coredumpv(bus->dev, dump, len + ramsize, GFP_KERNEL);
  45. +
  46. return 0;
  47. }