Skip to content

Commit 8e089e7

Browse files
ISCAS-Vulabjmberg-intel
authored andcommitted
wifi: brcm80211: fmac: Add error handling for brcmf_usb_dl_writeimage()
The function brcmf_usb_dl_writeimage() calls the function brcmf_usb_dl_cmd() but dose not check its return value. The 'state.state' and the 'state.bytes' are uninitialized if the function brcmf_usb_dl_cmd() fails. It is dangerous to use uninitialized variables in the conditions. Add error handling for brcmf_usb_dl_cmd() to jump to error handling path if the brcmf_usb_dl_cmd() fails and the 'state.state' and the 'state.bytes' are uninitialized. Improve the error message to report more detailed error information. Fixes: 71bb244 ("brcm80211: fmac: add USB support for bcm43235/6/8 chipsets") Cc: [email protected] # v3.4+ Signed-off-by: Wentao Liang <[email protected]> Acked-by: Arend van Spriel <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Johannes Berg <[email protected]>
1 parent 0fb15ae commit 8e089e7

File tree

1 file changed

+4
-2
lines changed
  • drivers/net/wireless/broadcom/brcm80211/brcmfmac

1 file changed

+4
-2
lines changed

drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -896,14 +896,16 @@ brcmf_usb_dl_writeimage(struct brcmf_usbdev_info *devinfo, u8 *fw, int fwlen)
896896
}
897897

898898
/* 1) Prepare USB boot loader for runtime image */
899-
brcmf_usb_dl_cmd(devinfo, DL_START, &state, sizeof(state));
899+
err = brcmf_usb_dl_cmd(devinfo, DL_START, &state, sizeof(state));
900+
if (err)
901+
goto fail;
900902

901903
rdlstate = le32_to_cpu(state.state);
902904
rdlbytes = le32_to_cpu(state.bytes);
903905

904906
/* 2) Check we are in the Waiting state */
905907
if (rdlstate != DL_WAITING) {
906-
brcmf_err("Failed to DL_START\n");
908+
brcmf_err("Invalid DL state: %u\n", rdlstate);
907909
err = -EINVAL;
908910
goto fail;
909911
}

0 commit comments

Comments
 (0)