Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Alessio Ferri" <alessio.ferri@mythread.it>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v4 4/5] bcma: add host driver for the BCM6362 integrated WLAN backplane
Date: Wed, 04 Nov 2026 20:07:38 +0000	[thread overview]
Message-ID: <sashiko-outbox-197993@kernel.org> (raw)
In-Reply-To: <20261104-bcm6362-wlan-v4-4-f001f6d75dc3@mythread.it>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] bcma: unconditional driver unregister in bcma_modexit() after init failure
- [Medium] bcma: memory and iomap leak in bcma_host_soc_bcm6362_probe() on scan error
--

commit 400b457ad79cb1893252ac704192c2032be3a329
Author: Alessio Ferri <alessio.ferri@mythread.it>

bcma: add host driver for the BCM6362 integrated WLAN backplane

This commit adds a host driver for the BCM6362 integrated WLAN bcma
backplane, handling clock enablement, resets, big-endian I/O ops, and
emulation of per-core control registers for wrapperless cores.

> diff --git a/drivers/bcma/host_soc_bcm6362.c b/drivers/bcma/host_soc_bcm6362.c
> new file mode 100644
> index 0000000000000..e8400cb624484
> --- /dev/null
> +++ b/drivers/bcma/host_soc_bcm6362.c
[ ... ]
> +static int bcma_host_soc_bcm6362_probe(struct platform_device *pdev)
> +{
[ ... ]
> +	err = bcma_bus_register(bus);
> +	if (err) {
> +		bcma_host_soc_bcm6362_power_off(host);
> +		return err;
> +	}

[Severity: Medium]
As reported by Sashiko on v2 [1], does bcma_host_soc_bcm6362_probe() leak
core structures and their ioremap() mappings if bcma_bus_register() fails?

When bcma_bus_register() calls bcma_bus_scan(), each discovered core is
allocated, mapped via ioremap() into core->io_addr, and appended to
bus->cores. If scanning a subsequent core fails (for example, returning
-ENOMEM or -EILSEQ in bcma_bus_scan()), bcma_bus_scan() returns the error
with any previously scanned cores still on bus->cores:

drivers/bcma/scan.c:bcma_bus_scan() {
    ...
		err = bcma_get_next_core(bus, &eromptr, NULL, core_num, core);
		if (err < 0) {
			kfree(core);
			...
			goto out;
		}
    ...
}

Because bcma_host_soc_bcm6362_probe() powers off and returns without
calling bcma_unregister_cores(bus), wouldn't those allocated cores and
their core->io_addr mappings be leaked?

> diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c
> index 72f045e6ed513..4ccc9fb98f616 100644
> --- a/drivers/bcma/main.c
> +++ b/drivers/bcma/main.c
> @@ -682,6 +682,11 @@ static int __init bcma_modinit(void)
>  		pr_err("SoC host initialization failed\n");
>  		err = 0;
>  	}
> +	err = bcma_host_soc_bcm6362_register_driver();
> +	if (err) {
> +		pr_err("BCM6362 WLAN host initialization failed\n");
> +		err = 0;
> +	}
>  #ifdef CONFIG_BCMA_HOST_PCI
>  	err = bcma_host_pci_init();
>  	if (err) {
> @@ -699,6 +704,7 @@ static void __exit bcma_modexit(void)
>  #ifdef CONFIG_BCMA_HOST_PCI
>  	bcma_host_pci_exit();
>  #endif
> +	bcma_host_soc_bcm6362_unregister_driver();

[Severity: Medium]
As reported by Sashiko on v2 [1], could calling
bcma_host_soc_bcm6362_unregister_driver() unconditionally in bcma_modexit()
trigger a warning if registration failed during module init?

In bcma_modinit(), if bcma_host_soc_bcm6362_register_driver() fails, the
error is logged and cleared to 0 so the module still loads, leaving
bcma_host_soc_bcm6362_driver.driver.p as NULL. When the module is later
unloaded, bcma_modexit() calls:

bcma_host_soc_bcm6362_unregister_driver()
  -> platform_driver_unregister()
    -> driver_unregister()

which checks if (!drv || !drv->p) and hits WARN(1, "Unexpected driver
unregister!\n").

[1] https://lore.kernel.org/r/20261012-bcm6362-wlan-v2-4-4752da7e0982@mythread.it

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261104-bcm6362-wlan-v4-0-f001f6d75dc3@mythread.it?part=4

  reply	other threads:[~2026-11-04 20:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-04 19:30 [PATCH v4 0/5] bcma: support the BCM6362 integrated WLAN backplane Alessio Ferri
2026-11-04 19:30 ` [PATCH v4 1/5] dt-bindings: bus: add Broadcom BCM6362 WLAN AXI backplane Alessio Ferri
2026-11-04 19:30 ` [PATCH v4 2/5] bcma: scan: support big-endian backplanes Alessio Ferri
2026-11-04 19:30 ` [PATCH v4 3/5] bcma: scan: accept wrapper-less cores on wrapper-less backplanes Alessio Ferri
2026-11-04 19:30 ` [PATCH v4 4/5] bcma: add host driver for the BCM6362 integrated WLAN backplane Alessio Ferri
2026-11-04 20:07   ` sashiko-bot [this message]
2026-11-04 19:30 ` [PATCH v4 5/5] MIPS: dts: bcm6362: add the " Alessio Ferri

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=sashiko-outbox-197993@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=alessio.ferri@mythread.it \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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