Skip to content

Commit 08424a0

Browse files
ISCAS-Vulabgregkh
authored andcommitted
wifi: brcm80211: fmac: Add error handling for brcmf_usb_dl_writeimage()
commit 8e089e7 upstream. 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]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 8daa71c commit 08424a0

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
@@ -903,14 +903,16 @@ brcmf_usb_dl_writeimage(struct brcmf_usbdev_info *devinfo, u8 *fw, int fwlen)
903903
}
904904

905905
/* 1) Prepare USB boot loader for runtime image */
906-
brcmf_usb_dl_cmd(devinfo, DL_START, &state, sizeof(state));
906+
err = brcmf_usb_dl_cmd(devinfo, DL_START, &state, sizeof(state));
907+
if (err)
908+
goto fail;
907909

908910
rdlstate = le32_to_cpu(state.state);
909911
rdlbytes = le32_to_cpu(state.bytes);
910912

911913
/* 2) Check we are in the Waiting state */
912914
if (rdlstate != DL_WAITING) {
913-
brcmf_err("Failed to DL_START\n");
915+
brcmf_err("Invalid DL state: %u\n", rdlstate);
914916
err = -EINVAL;
915917
goto fail;
916918
}

0 commit comments

Comments
 (0)