mac80211: backport today's brcmfmac changes
[openwrt/openwrt.git] / package / kernel / mac80211 / patches / 377-brcmfmac-treat-0-as-end-of-comment-when-parsing-NVRA.patch
1 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
2 Date: Wed, 20 May 2015 13:59:54 +0200
3 Subject: [PATCH] brcmfmac: treat \0 as end of comment when parsing NVRAM
4 MIME-Version: 1.0
5 Content-Type: text/plain; charset=UTF-8
6 Content-Transfer-Encoding: 8bit
7
8 This fixes brcmfmac dealing with NVRAM coming from platform e.g. from a
9 flash MTD partition. In such cases entries are separated by \0 instead
10 of \n which caused ignoring whole content after the first "comment".
11 While platform NVRAM doesn't usually contain comments, we switch to
12 COMMENT state after e.g. finding an unexpected char in key name.
13
14 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
15 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
16 ---
17
18 --- a/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
19 +++ b/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
20 @@ -162,17 +162,20 @@ brcmf_nvram_handle_value(struct nvram_pa
21 static enum nvram_parser_state
22 brcmf_nvram_handle_comment(struct nvram_parser *nvp)
23 {
24 - char *eol, *sol;
25 + char *eoc, *sol;
26
27 sol = (char *)&nvp->fwnv->data[nvp->pos];
28 - eol = strchr(sol, '\n');
29 - if (eol == NULL)
30 - return END;
31 + eoc = strchr(sol, '\n');
32 + if (!eoc) {
33 + eoc = strchr(sol, '\0');
34 + if (!eoc)
35 + return END;
36 + }
37
38 /* eat all moving to next line */
39 nvp->line++;
40 nvp->column = 1;
41 - nvp->pos += (eol - sol) + 1;
42 + nvp->pos += (eoc - sol) + 1;
43 return IDLE;
44 }
45