Skip to content

Commit

Permalink
brcmfmac: firmware: Fix crash in brcm_alt_fw_path
Browse files Browse the repository at this point in the history
commit 665408f upstream.

The call to brcm_alt_fw_path in brcmf_fw_get_firmwares is not protected
by a check to the validity of the fwctx->req->board_type pointer. This
results in a crash in strlcat when, for example, the WLAN chip is found
in a USB dongle.

Prevent the crash by adding the necessary check.

See: raspberrypi/linux#4833

Fixes: 5ff0139 ("brcmfmac: firmware: Allow per-board firmware binaries")
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220118154514.3245524-1-phil@raspberrypi.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
pelwell authored and gregkh committed Feb 23, 2022
1 parent ee67ed3 commit ebeba97
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
Expand Up @@ -693,7 +693,7 @@ int brcmf_fw_get_firmwares(struct device *dev, struct brcmf_fw_request *req,
{
struct brcmf_fw_item *first = &req->items[0];
struct brcmf_fw *fwctx;
char *alt_path;
char *alt_path = NULL;
int ret;

brcmf_dbg(TRACE, "enter: dev=%s\n", dev_name(dev));
Expand All @@ -712,7 +712,9 @@ int brcmf_fw_get_firmwares(struct device *dev, struct brcmf_fw_request *req,
fwctx->done = fw_cb;

/* First try alternative board-specific path if any */
alt_path = brcm_alt_fw_path(first->path, fwctx->req->board_type);
if (fwctx->req->board_type)
alt_path = brcm_alt_fw_path(first->path,
fwctx->req->board_type);
if (alt_path) {
ret = request_firmware_nowait(THIS_MODULE, true, alt_path,
fwctx->dev, GFP_KERNEL, fwctx,
Expand Down

0 comments on commit ebeba97

Please sign in to comment.