mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v4] brcm80211: fmac: Add error log in brcmf_usb_dl_cmd()
@ 2025-04-15 12:20 Wentao Liang
  2025-04-19  6:46 ` Arend Van Spriel
  0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2025-04-15 12:20 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>
---
v4: Fix spelling problem.
v3: Change patch name and comment. Move error log into brcmf_usb_dl_cmd().
v2: Remove redundant bailing out code.

 .../wireless/broadcom/brcm80211/brcmfmac/usb.c   | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
index d06c724f63d9..a11a6d9f3c2b 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
@@ -744,12 +744,16 @@ static int brcmf_usb_dl_cmd(struct brcmf_usbdev_info *devinfo, u8 cmd,
 	char *tmpbuf;
 	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;
@@ -783,6 +787,10 @@ static int brcmf_usb_dl_cmd(struct brcmf_usbdev_info *devinfo, u8 cmd,
 finalize:
 	kfree(tmpbuf);
 	return ret;
+
+err:
+	brcmf_err("dl cmd %u failed: err=%d\n", cmd, ret);
+	return ret;
 }
 
 static bool
-- 
2.42.0.windows.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v4] brcm80211: fmac: Add error log in brcmf_usb_dl_cmd()
  2025-04-15 12:20 [PATCH v4] brcm80211: fmac: Add error log in brcmf_usb_dl_cmd() Wentao Liang
@ 2025-04-19  6:46 ` Arend Van Spriel
  0 siblings, 0 replies; 2+ messages in thread
From: Arend Van Spriel @ 2025-04-19  6:46 UTC (permalink / raw)
  To: Wentao Liang, kvalo
  Cc: linux-wireless, brcm80211, brcm80211-dev-list.pdl, linux-kernel

On April 15, 2025 2:21:37 PM Wentao Liang <vulab@iscas.ac.cn> 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.
>
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
> v4: Fix spelling problem.
> v3: Change patch name and comment. Move error log into brcmf_usb_dl_cmd().
> v2: Remove redundant bailing out code.
>
> .../wireless/broadcom/brcm80211/brcmfmac/usb.c   | 16 ++++++++++++----
> 1 file changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c 
> b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
> index d06c724f63d9..a11a6d9f3c2b 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
> @@ -744,12 +744,16 @@ static int brcmf_usb_dl_cmd(struct brcmf_usbdev_info 
> *devinfo, u8 cmd,
> char *tmpbuf;
> 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;
> @@ -783,6 +787,10 @@ static int brcmf_usb_dl_cmd(struct brcmf_usbdev_info 
> *devinfo, u8 cmd,
> finalize:

The finalize label is used for failure path as well. So I suggest to get 
rid of it requiring modified patch like:

- finalize:
        kfree(tmpbuf);
-       return ret;
+.     return 0;
+
+ err:

+      brcmf_err("dl cmd %u failed: err=%d\n", cmd, ret);
+      kfree(tmpbuf);
+      return ret;
}

Obviously this means tmpbuf should be NULL initialized.

Regards,
Arend



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-04-19  6:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-15 12:20 [PATCH v4] brcm80211: fmac: Add error log in brcmf_usb_dl_cmd() Wentao Liang
2025-04-19  6:46 ` 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®