diff options
author | Rafał Miłecki <rafal@milecki.pl> | 2019-01-08 10:01:08 +0100 |
---|---|---|
committer | Rafał Miłecki <rafal@milecki.pl> | 2019-01-08 10:12:07 +0100 |
commit | a8cc06c5371eca2ae8ab4511c7136d0ebd9ee3bc (patch) | |
tree | 7b591eb33402aa256ea777d7300a6a593a4b4c1e /package/kernel/mac80211/patches/355-v5.0-0003-brcmfmac-Add-support-for-first-trying-to-get-a-board.patch | |
parent | c5c20f510a19f0eb5500fefde1f366f48c168e85 (diff) | |
download | openwrt-a8cc06c5371eca2ae8ab4511c7136d0ebd9ee3bc.tar.gz openwrt-a8cc06c5371eca2ae8ab4511c7136d0ebd9ee3bc.tar.bz2 openwrt-a8cc06c5371eca2ae8ab4511c7136d0ebd9ee3bc.zip |
mac80211: brcmfmac: backport firmware loading changes & fix memory bugs
This pick most of brcmfmac changes backported into the master in commits
5932eb690f24 ("mac80211: brcmfmac: backport firmware loading cleanup")
3eab6b8275b2 ("mac80211: brcmfmac: backport NVRAM loading improvements")
529c95cc15dc ("mac80211: brcmfmac: fix use-after-free & possible NULL pointer dereference")
It's more than would be normally backported into a stable branch but it
seems required. Firmware loading cleanups are needed to allow fix memory
bugs in a reliable way. Memory fixes are really important to avoid
corrupting memory and risking a NULL pointer dereference.
Hopefully this stuff has received enough testing in the master.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Diffstat (limited to 'package/kernel/mac80211/patches/355-v5.0-0003-brcmfmac-Add-support-for-first-trying-to-get-a-board.patch')
-rw-r--r-- | package/kernel/mac80211/patches/355-v5.0-0003-brcmfmac-Add-support-for-first-trying-to-get-a-board.patch | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/package/kernel/mac80211/patches/355-v5.0-0003-brcmfmac-Add-support-for-first-trying-to-get-a-board.patch b/package/kernel/mac80211/patches/355-v5.0-0003-brcmfmac-Add-support-for-first-trying-to-get-a-board.patch new file mode 100644 index 0000000000..727dcbe85a --- /dev/null +++ b/package/kernel/mac80211/patches/355-v5.0-0003-brcmfmac-Add-support-for-first-trying-to-get-a-board.patch @@ -0,0 +1,77 @@ +From eae8e50669e15002b195177212a6e25afbe7cf4d Mon Sep 17 00:00:00 2001 +From: Hans de Goede <hdegoede@redhat.com> +Date: Wed, 10 Oct 2018 13:01:00 +0200 +Subject: [PATCH] brcmfmac: Add support for first trying to get a board + specific nvram file + +The nvram files which some brcmfmac chips need are board-specific. To be +able to distribute these as part of linux-firmware, so that devices with +such a wifi chip will work OOTB, multiple (one per board) versions must +co-exist under /lib/firmware. + +This commit adds support for callers of the brcmfmac/firmware.c code to +pass in a board_type parameter through the request structure. + +If that parameter is set then the code will first try to load +chipmodel.board_type.txt before falling back to the old chipmodel.txt name. + +Signed-off-by: Hans de Goede <hdegoede@redhat.com> +Signed-off-by: Kalle Valo <kvalo@codeaurora.org> +--- + .../broadcom/brcm80211/brcmfmac/firmware.c | 27 +++++++++++++++++++++- + .../broadcom/brcm80211/brcmfmac/firmware.h | 1 + + 2 files changed, 27 insertions(+), 1 deletion(-) + +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c +@@ -532,6 +532,31 @@ static int brcmf_fw_complete_request(con + return (cur->flags & BRCMF_FW_REQF_OPTIONAL) ? 0 : ret; + } + ++static int brcmf_fw_request_firmware(const struct firmware **fw, ++ struct brcmf_fw *fwctx) ++{ ++ struct brcmf_fw_item *cur = &fwctx->req->items[fwctx->curpos]; ++ int ret; ++ ++ /* nvram files are board-specific, first try a board-specific path */ ++ if (cur->type == BRCMF_FW_TYPE_NVRAM && fwctx->req->board_type) { ++ char alt_path[BRCMF_FW_NAME_LEN]; ++ ++ strlcpy(alt_path, cur->path, BRCMF_FW_NAME_LEN); ++ /* strip .txt at the end */ ++ alt_path[strlen(alt_path) - 4] = 0; ++ strlcat(alt_path, ".", BRCMF_FW_NAME_LEN); ++ strlcat(alt_path, fwctx->req->board_type, BRCMF_FW_NAME_LEN); ++ strlcat(alt_path, ".txt", BRCMF_FW_NAME_LEN); ++ ++ ret = request_firmware(fw, alt_path, fwctx->dev); ++ if (ret == 0) ++ return ret; ++ } ++ ++ return request_firmware(fw, cur->path, fwctx->dev); ++} ++ + static void brcmf_fw_request_done(const struct firmware *fw, void *ctx) + { + struct brcmf_fw *fwctx = ctx; +@@ -544,7 +569,7 @@ static void brcmf_fw_request_done(const + + while (ret == 0 && ++fwctx->curpos < fwctx->req->n_items) { + cur = &fwctx->req->items[fwctx->curpos]; +- request_firmware(&fw, cur->path, fwctx->dev); ++ brcmf_fw_request_firmware(&fw, fwctx); + ret = brcmf_fw_complete_request(fw, ctx); + } + +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h +@@ -70,6 +70,7 @@ struct brcmf_fw_request { + u16 domain_nr; + u16 bus_nr; + u32 n_items; ++ const char *board_type; + struct brcmf_fw_item items[0]; + }; + |