[PATCH] spi: meson-spicc: Fix double-put in remove path

Felix Gu posted 1 patch 1 week, 5 days ago
drivers/spi/spi-meson-spicc.c | 2 --
1 file changed, 2 deletions(-)
[PATCH] spi: meson-spicc: Fix double-put in remove path
Posted by Felix Gu 1 week, 5 days ago
meson_spicc_probe() registers the controller with
devm_spi_register_controller(), so teardown already drops the
controller reference via devm cleanup.

Calling spi_controller_put() again in meson_spicc_remove()
causes a double-put.

Fixes: 8311ee2164c5 ("spi: meson-spicc: fix memory leak in meson_spicc_remove")
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
---
 drivers/spi/spi-meson-spicc.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/spi/spi-meson-spicc.c b/drivers/spi/spi-meson-spicc.c
index a7001b9e36e6..57768da3205d 100644
--- a/drivers/spi/spi-meson-spicc.c
+++ b/drivers/spi/spi-meson-spicc.c
@@ -1101,8 +1101,6 @@ static void meson_spicc_remove(struct platform_device *pdev)
 
 	/* Disable SPI */
 	writel(0, spicc->base + SPICC_CONREG);
-
-	spi_controller_put(spicc->host);
 }
 
 static const struct meson_spicc_data meson_spicc_gx_data = {

---
base-commit: 785f0eb2f85decbe7c1ef9ae922931f0194ffc2e
change-id: 20260322-rockchip-2a6021826137

Best regards,
-- 
Felix Gu <ustc.gu@gmail.com>
Re: [PATCH] spi: meson-spicc: Fix double-put in remove path
Posted by Mark Brown 1 week, 4 days ago
On Sun, 22 Mar 2026 21:29:56 +0800, Felix Gu wrote:
> spi: meson-spicc: Fix double-put in remove path

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-7.0

Thanks!

[1/1] spi: meson-spicc: Fix double-put in remove path
      https://git.kernel.org/broonie/spi/c/63542bb402b7

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark
Re: [PATCH] spi: meson-spicc: Fix double-put in remove path
Posted by Johan Hovold 1 week, 4 days ago
On Sun, Mar 22, 2026 at 09:29:56PM +0800, Felix Gu wrote:
> meson_spicc_probe() registers the controller with
> devm_spi_register_controller(), so teardown already drops the
> controller reference via devm cleanup.
> 
> Calling spi_controller_put() again in meson_spicc_remove()
> causes a double-put.

Indeed it does: 

Reviewed-by: Johan Hovold <johan@kernel.org>

> Fixes: 8311ee2164c5 ("spi: meson-spicc: fix memory leak in meson_spicc_remove")

While only root can trigger this it should probably still go stable:

Cc: stable@vger.kernel.org

> Signed-off-by: Felix Gu <ustc.gu@gmail.com>

How did you find this one? Are you using some kind of static analysis
tool or LLM?

Johan
Re: [PATCH] spi: meson-spicc: Fix double-put in remove path
Posted by Felix Gu 1 week, 4 days ago
> Indeed it does:
>
> Reviewed-by: Johan Hovold <johan@kernel.org>
>
> > Fixes: 8311ee2164c5 ("spi: meson-spicc: fix memory leak in meson_spicc_remove")
>
> While only root can trigger this it should probably still go stable:
>
> Cc: stable@vger.kernel.org
>
> > Signed-off-by: Felix Gu <ustc.gu@gmail.com>
>
> How did you find this one? Are you using some kind of static analysis
> tool or LLM?
>
> Johan
Hi Johan,
Just code review, I have fixed a similar one before.

Best regards,
Felix
Re: spi: meson-spicc: Fix double-put in remove path
Posted by Markus Elfring 1 week, 4 days ago
> Just code review, I have fixed a similar one before.

Can such information mean also that any source code search approaches
would be involved here?
https://en.wikipedia.org/wiki/Code_review

Regards,
Markus
Re: spi: meson-spicc: Fix double-put in remove path
Posted by Mark Brown 1 week, 4 days ago
On Mon, Mar 23, 2026 at 07:44:21PM +0100, Markus Elfring wrote:
> > Just code review, I have fixed a similar one before.
> 
> Can such information mean also that any source code search approaches
> would be involved here?
> https://en.wikipedia.org/wiki/Code_review

Feel free to ignore Markus, he has a long history of sending
unhelpful review comments and continues to ignore repeated requests
to stop.
Re: [PATCH] spi: meson-spicc: Fix double-put in remove path
Posted by Markus Elfring 1 week, 5 days ago
> meson_spicc_probe() registers the controller with
> devm_spi_register_controller(), so teardown already drops the
> controller reference via devm cleanup.

Were any source code analysis tools involved here?


> Calling spi_controller_put() again in meson_spicc_remove()
> causes a double-put.

Do any contributors care more for another development requirement?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v7.0-rc4#n94

Regards,
Markus