brcmfmac: Protect against reprobing
authorPhil Elwell <phil@raspberrypi.com>
Wed, 3 Nov 2021 11:53:13 +0000 (11:53 +0000)
committerPhil Elwell <phil@raspberrypi.com>
Wed, 3 Nov 2021 16:46:59 +0000 (16:46 +0000)
It is important to reinitialise the firmware array pointers to protect
against the case that the brcmfmac driver is reprobed without first
being unloaded.

The potential hazard was noticed while investigating
https://github.com/raspberrypi/firmware/issues/1644 .

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c

index 21dbbf9..c8609fe 100644 (file)
@@ -651,8 +651,8 @@ static const struct brcmf_firmware_mapping sdio_fwnames[] = {
        BRCMF_FW_ENTRY(CY_CC_43012_CHIP_ID, 0xFFFFFFFF, 43012)
 };
 
-static const struct brcmf_firmware_mapping *brcmf_sdio_fwnames = sdio_fwnames;
-static u32 brcmf_sdio_fwnames_count = ARRAY_SIZE(sdio_fwnames);
+static const struct brcmf_firmware_mapping *brcmf_sdio_fwnames;
+static u32 brcmf_sdio_fwnames_count;
 
 #define TXCTL_CREDITS  2
 
@@ -4539,6 +4539,8 @@ struct brcmf_sdio *brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev)
 
        brcmf_dbg(INFO, "completed!!\n");
 
+       brcmf_sdio_fwnames = sdio_fwnames;
+       brcmf_sdio_fwnames_count = ARRAY_SIZE(sdio_fwnames);
        of_fwnames = brcmf_of_fwnames(sdiodev->dev, &of_fw_count);
        if (of_fwnames)
                fwnames = devm_kcalloc(sdiodev->dev,