brcmfmac: Only match complete feature names

The firmware advertises its features as a string of words separated by
spaces. Ensure that feature names are only matched in their entirety.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
This commit is contained in:
Phil Elwell
2024-02-05 15:25:30 +00:00
committed by Dom Cobley
parent a031979b5b
commit 258e478444

View File

@@ -241,7 +241,14 @@ static void brcmf_feat_firmware_capabilities(struct brcmf_if *ifp)
brcmf_dbg(INFO, "[ %s]\n", caps);
for (i = 0; i < ARRAY_SIZE(brcmf_fwcap_map); i++) {
if (strnstr(caps, brcmf_fwcap_map[i].fwcap_id, sizeof(caps))) {
const char *match = strnstr(caps, brcmf_fwcap_map[i].fwcap_id, sizeof(caps));
if (match) {
char endc;
if (match != caps && match[-1] != ' ')
continue;
endc = match[strlen(brcmf_fwcap_map[i].fwcap_id)];
if (endc != '\0' && endc != ' ')
continue;
id = brcmf_fwcap_map[i].feature;
brcmf_dbg(INFO, "enabling feature: %s\n",
brcmf_feat_names[id]);