brcmfmac: Fix driver crash on USB control transfer timeout

When the control transfer gets timed out, the error status
was returned without killing that urb, this leads to using
the same urb. This issue causes the kernel crash as the same
urb is sumbitted multiple times. The fix is to kill the
urb for timeout transfer before returning error

Signed-off-by: Raveendran Somu <raveendran.somu@cypress.com>
Signed-off-by: Chi-hsien Lin <chi-hsien.lin@cypress.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/1585124429-97371-2-git-send-email-chi-hsien.lin@cypress.com
This commit is contained in:
Raveendran Somu 2020-03-25 03:20:24 -05:00 committed by Kalle Valo
parent 0985d3a410
commit 93a5bfbc7c

View File

@ -328,11 +328,12 @@ static int brcmf_usb_tx_ctlpkt(struct device *dev, u8 *buf, u32 len)
return err; return err;
} }
timeout = brcmf_usb_ioctl_resp_wait(devinfo); timeout = brcmf_usb_ioctl_resp_wait(devinfo);
clear_bit(0, &devinfo->ctl_op);
if (!timeout) { if (!timeout) {
brcmf_err("Txctl wait timed out\n"); brcmf_err("Txctl wait timed out\n");
usb_kill_urb(devinfo->ctl_urb);
err = -EIO; err = -EIO;
} }
clear_bit(0, &devinfo->ctl_op);
return err; return err;
} }
@ -358,11 +359,12 @@ static int brcmf_usb_rx_ctlpkt(struct device *dev, u8 *buf, u32 len)
} }
timeout = brcmf_usb_ioctl_resp_wait(devinfo); timeout = brcmf_usb_ioctl_resp_wait(devinfo);
err = devinfo->ctl_urb_status; err = devinfo->ctl_urb_status;
clear_bit(0, &devinfo->ctl_op);
if (!timeout) { if (!timeout) {
brcmf_err("rxctl wait timed out\n"); brcmf_err("rxctl wait timed out\n");
usb_kill_urb(devinfo->ctl_urb);
err = -EIO; err = -EIO;
} }
clear_bit(0, &devinfo->ctl_op);
if (!err) if (!err)
return devinfo->ctl_urb_actual_length; return devinfo->ctl_urb_actual_length;
else else