From: Wentao Liang Date: Tue, 22 Apr 2025 06:59:38 +0000 (+0800) Subject: wifi: brcm80211: fmac: Add error log in brcmf_usb_dl_cmd() X-Git-Tag: v6.16-rc1~132^2~157^2~44 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a3cdd0899b8b0e385a48b32f48e0dfc70d3c1ada;p=thirdparty%2Fkernel%2Fstable.git wifi: brcm80211: fmac: Add error log in brcmf_usb_dl_cmd() In brcmf_usb_dl_cmd(), the error logging is not enough to describe the error state. And some caller of the brcmf_usb_dl_cmd() does not handle its error. An error log in brcmf_usb_dl_cmd() is needed to prevent silent failure. Add error handling in brcmf_usb_dl_cmd() to log the command id and error code in the brcmf_usb_dl_cmd() fails. In this way, every invocation of the function logs a message upon failure. Signed-off-by: Wentao Liang Acked-by: Arend van Spriel Link: https://patch.msgid.link/20250422065938.2345-1-vulab@iscas.ac.cn Signed-off-by: Johannes Berg --- diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c index 2821c27f317ee..40c2a49b8ae9a 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c @@ -741,15 +741,19 @@ static int brcmf_usb_dl_cmd(struct brcmf_usbdev_info *devinfo, u8 cmd, void *buffer, int buflen) { int ret; - char *tmpbuf; + char *tmpbuf = NULL; u16 size; - if ((!devinfo) || (devinfo->ctl_urb == NULL)) - return -EINVAL; + if (!devinfo || !devinfo->ctl_urb) { + ret = -EINVAL; + goto err; + } tmpbuf = kmalloc(buflen, GFP_ATOMIC); - if (!tmpbuf) - return -ENOMEM; + if (!tmpbuf) { + ret = -ENOMEM; + goto err; + } size = buflen; devinfo->ctl_urb->transfer_buffer_length = size; @@ -770,18 +774,23 @@ static int brcmf_usb_dl_cmd(struct brcmf_usbdev_info *devinfo, u8 cmd, ret = usb_submit_urb(devinfo->ctl_urb, GFP_ATOMIC); if (ret < 0) { brcmf_err("usb_submit_urb failed %d\n", ret); - goto finalize; + goto err; } if (!brcmf_usb_ioctl_resp_wait(devinfo)) { usb_kill_urb(devinfo->ctl_urb); ret = -ETIMEDOUT; + goto err; } else { memcpy(buffer, tmpbuf, buflen); } -finalize: kfree(tmpbuf); + return 0; + +err: + kfree(tmpbuf); + brcmf_err("dl cmd %u failed: err=%d\n", cmd, ret); return ret; }