linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] brcmfmac: firmware: Fix crash in brcm_alt_fw_path
@ 2022-01-18 15:45 Phil Elwell
  2022-01-19  6:01 ` Kalle Valo
  2022-01-28 14:07 ` Kalle Valo
  0 siblings, 2 replies; 12+ messages in thread
From: Phil Elwell @ 2022-01-18 15:45 UTC (permalink / raw)
  To: Arend van Spriel, Chung-hsien Hsu, Kalle Valo, David S. Miller,
	Jakub Kicinski, Linus Walleij, Phil Elwell, linux-wireless,
	brcm80211-dev-list.pdl, SHA-cyfmac-dev-list

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: https://github.com/raspberrypi/linux/issues/4833

Fixes: 5ff013914c62 ("brcmfmac: firmware: Allow per-board firmware binaries")
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
index 0eb13e5df5177..d99140960a820 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
@@ -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));
@@ -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,
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-01-28 14:07 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-18 15:45 [PATCH] brcmfmac: firmware: Fix crash in brcm_alt_fw_path Phil Elwell
2022-01-19  6:01 ` Kalle Valo
2022-01-19  8:53   ` Phil Elwell
2022-01-19 10:00     ` Kalle Valo
2022-01-19 15:48     ` Arend van Spriel
2022-01-27 12:08       ` Kalle Valo
2022-01-27 12:59         ` Arend van Spriel
2022-01-27 13:17           ` Kalle Valo
2022-01-27 14:30             ` Arend van Spriel
2022-01-27 15:36               ` Kalle Valo
2022-01-27 16:22                 ` Arend van Spriel
2022-01-28 14:07 ` Kalle Valo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).