mac80211: backport brcmfmac fixes & debugging helpers from 4.18
[openwrt/openwrt.git] / package / kernel / mac80211 / patches / 335-v4.18-0004-brcmfmac-validate-user-provided-data-for-memdump-bef.patch
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
7 In patch "brcmfmac: add support for sysfs initiated coredump", a new
8 scenario of brcmf_debug_create_memdump was added in which the user of
9 the function might not necessarily provide prefix data. Hence the
10 function should not assume the data is always valid and should perform a
11 check before copying.
12
13 Reviewed-by: Arend van Spriel <arend.vanspriel@broadcom.com>
14 Signed-off-by: Franky Lin <franky.lin@broadcom.com>
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/debug.c | 3 ++-
19 1 file changed, 2 insertions(+), 1 deletion(-)
20
21 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c
22 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c
23 @@ -40,7 +40,8 @@ int brcmf_debug_create_memdump(struct br
24 if (!dump)
25 return -ENOMEM;
26
27 - memcpy(dump, data, len);
28 + if (data && len > 0)
29 + memcpy(dump, data, len);
30 err = brcmf_bus_get_memdump(bus, dump + len, ramsize);
31 if (err) {
32 vfree(dump);