From: Arend van Spriel <arend.vanspriel@broadcom.com>
To: Wentao Liang <vulab@iscas.ac.cn>, kvalo@kernel.org
Cc: christophe.jaillet@wanadoo.fr, megi@xff.cz,
saikrishnag@marvell.com, linux-wireless@vger.kernel.org,
brcm80211@lists.linux.dev, brcm80211-dev-list.pdl@broadcom.com,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] brcm80211: fmac: Add error check for brcmf_usb_dlneeded()
Date: Wed, 9 Apr 2025 14:11:02 +0200 [thread overview]
Message-ID: <d791185d-6a23-4c6f-8a93-d5464409939a@broadcom.com> (raw)
In-Reply-To: <20250406081930.2909-1-vulab@iscas.ac.cn>
On 4/6/2025 10:19 AM, Wentao Liang wrote:
> The function brcmf_usb_dlneeded() calls the function brcmf_usb_dl_cmd()
> but dose not check its return value. The 'id.chiprev' is uninitialized if
> the function brcmf_usb_dl_cmd() fails, and may propagate to
> 'devinfo->bus_pub.chiprev'.
>
> Add error handling for brcmf_usb_dl_cmd() to return the function if the
> 'id.chiprev' is uninitialized.
Thanks for the patch, but NAK. Let me explain why below...
> Fixes: 71bb244ba2fd ("brcm80211: fmac: add USB support for bcm43235/6/8 chipsets")
> Cc: stable@vger.kernel.org # v3.4+
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
> drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
> index 2821c27f317e..50dddac8a2ab 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
> @@ -790,6 +790,7 @@ brcmf_usb_dlneeded(struct brcmf_usbdev_info *devinfo)
> {
> struct bootrom_id_le id;
> u32 chipid, chiprev;
> + int err;
>
> brcmf_dbg(USB, "Enter\n");
>
> @@ -798,7 +799,11 @@ brcmf_usb_dlneeded(struct brcmf_usbdev_info *devinfo)
>
> /* Check if firmware downloaded already by querying runtime ID */
> id.chip = cpu_to_le32(0xDEAD);
> - brcmf_usb_dl_cmd(devinfo, DL_GETVER, &id, sizeof(id));
> + err = brcmf_usb_dl_cmd(devinfo, DL_GETVER, &id, sizeof(id));
> + if (err) {
> + brcmf_err("DL_GETID Failed\n");
> + return false;
The boolean return value does not indicate pass or fail. It answers the
question implied by the function name brcmf_usb_dlneeded(), ie. is the
USB device running firmware (false) or do we need to download firmware
(true). So returning false here is not going to help us.
The id.chip is initialized to 0xDEAD so upon a failure that value is
being passed to brcmf_usb_prepare_fw_request() which will consequently
return NULL, because we do not support a 0xDEAD chip. So there is no
need to bail out here. Just print the failure message is enough although
I would suggest to include the err value:
- brcmf_usb_dl_cmd(devinfo, DL_GETVER, &id, sizeof(id));
+ err = brcmf_usb_dl_cmd(devinfo, DL_GETVER, &id, sizeof(id));
+ if (err)
+ brcmf_err("DL_GETVER failed: err=%d\n", err);
Regards,
Arend
next prev parent reply other threads:[~2025-04-09 12:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-06 8:19 Wentao Liang
2025-04-09 8:16 ` Markus Elfring
2025-04-09 12:11 ` Arend van Spriel [this message]
2025-04-09 15:03 ` Arend Van Spriel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d791185d-6a23-4c6f-8a93-d5464409939a@broadcom.com \
--to=arend.vanspriel@broadcom.com \
--cc=brcm80211-dev-list.pdl@broadcom.com \
--cc=brcm80211@lists.linux.dev \
--cc=christophe.jaillet@wanadoo.fr \
--cc=kvalo@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=megi@xff.cz \
--cc=saikrishnag@marvell.com \
--cc=stable@vger.kernel.org \
--cc=vulab@iscas.ac.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®