331-v4.18-0007-brcmfmac-validate-user-provided-data-for-memdump-bef.patch 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. From d2af9b566554e01f9ad67b330ce569dbc130e5d3 Mon Sep 17 00:00:00 2001
  2. From: Franky Lin <franky.lin@broadcom.com>
  3. Date: Wed, 16 May 2018 14:12:01 +0200
  4. Subject: [PATCH] brcmfmac: validate user provided data for memdump before
  5. copying
  6. In patch "brcmfmac: add support for sysfs initiated coredump", a new
  7. scenario of brcmf_debug_create_memdump was added in which the user of
  8. the function might not necessarily provide prefix data. Hence the
  9. function should not assume the data is always valid and should perform a
  10. check before copying.
  11. Reviewed-by: Arend van Spriel <arend.vanspriel@broadcom.com>
  12. Signed-off-by: Franky Lin <franky.lin@broadcom.com>
  13. Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
  14. Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  15. ---
  16. drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c | 3 ++-
  17. 1 file changed, 2 insertions(+), 1 deletion(-)
  18. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c
  19. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c
  20. @@ -42,7 +42,8 @@ int brcmf_debug_create_memdump(struct br
  21. if (!dump)
  22. return -ENOMEM;
  23. - memcpy(dump, data, len);
  24. + if (data && len > 0)
  25. + memcpy(dump, data, len);
  26. err = brcmf_bus_get_memdump(bus, dump + len, ramsize);
  27. if (err) {
  28. vfree(dump);