* [PATCH v5] brcm80211: fmac: Add error log in brcmf_usb_dl_cmd()
@ 2025-04-22 6:59 Wentao Liang
2025-04-22 11:39 ` Arend van Spriel
0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2025-04-22 6:59 UTC (permalink / raw)
To: arend.vanspriel, kvalo
Cc: linux-wireless, brcm80211, brcm80211-dev-list.pdl, linux-kernel,
Wentao Liang
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 <vulab@iscas.ac.cn>
---
v5: Remove finalize label.
v4: Fix spelling problem.
v3: Change patch name and comment. Move error log into brcmf_usb_dl_cmd().
v2: Remove redundant bailing out code.
.../broadcom/brcm80211/brcmfmac/usb.c | 23 +++++++++++++------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
index d06c724f63d9..b056336d5da6 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;
}
--
2.42.0.windows.2
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH v5] brcm80211: fmac: Add error log in brcmf_usb_dl_cmd()
2025-04-22 6:59 [PATCH v5] brcm80211: fmac: Add error log in brcmf_usb_dl_cmd() Wentao Liang
@ 2025-04-22 11:39 ` Arend van Spriel
0 siblings, 0 replies; 2+ messages in thread
From: Arend van Spriel @ 2025-04-22 11:39 UTC (permalink / raw)
To: Wentao Liang, kvalo
Cc: linux-wireless, brcm80211, brcm80211-dev-list.pdl, linux-kernel
On 4/22/2025 8:59 AM, Wentao Liang wrote:
> 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.
Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
> v5: Remove finalize label.
> v4: Fix spelling problem.
> v3: Change patch name and comment. Move error log into brcmf_usb_dl_cmd().
> v2: Remove redundant bailing out code.
>
> .../broadcom/brcm80211/brcmfmac/usb.c | 23 +++++++++++++------
> 1 file changed, 16 insertions(+), 7 deletions(-)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-04-22 11:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-22 6:59 [PATCH v5] brcm80211: fmac: Add error log in brcmf_usb_dl_cmd() Wentao Liang
2025-04-22 11:39 ` Arend van Spriel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®