spi: axiado: Fix double-free in ax_spi_probe()
Subsystems (3)
PATCH 1/1 spi: axiado: Fix double-free in ax_spi_probe()
ctlr is allocated using devm_spi_alloc_host(), which automatically handles reference counting via the devm framework.
Calling spi_controller_put() manually in the probe error path is redundant and results in a double-free.
--- drivers/spi/spi-axiado.c | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-)
drivers/spi/spi-axiado.c +11 -20
@@ -765,30 +765,22 @@ static int ax_spi_probe(struct platform_device *pdev)platform_set_drvdata (pdev, ctlr); xspi->regs =devm_platform_ioremap_resource (pdev,0 ); -if (IS_ERR (xspi->regs)) { - ret =PTR_ERR (xspi->regs); - goto remove_ctlr; - } +if (IS_ERR (xspi->regs)) +return PTR_ERR (xspi->regs); xspi->pclk =devm_clk_get (&pdev->dev,"pclk" ); -if (IS_ERR (xspi->pclk)) { -dev_err (&pdev->dev,"pclk clock not found.\n" ); - ret =PTR_ERR (xspi->pclk); - goto remove_ctlr; - } +if (IS_ERR (xspi->pclk)) +return dev_err_probe (&pdev->dev,PTR_ERR (xspi->pclk), +"pclk clock not found.\n" ); xspi->ref_clk =devm_clk_get (&pdev->dev,"ref" ); -if (IS_ERR (xspi->ref_clk)) { -dev_err (&pdev->dev,"ref clock not found.\n" ); - ret =PTR_ERR (xspi->ref_clk); - goto remove_ctlr; - } +if (IS_ERR (xspi->ref_clk)) +return dev_err_probe (&pdev->dev,PTR_ERR (xspi->ref_clk), +"ref clock not found.\n" ); ret =clk_prepare_enable (xspi->pclk); -if (ret) { -dev_err (&pdev->dev,"Unable to enable APB clock.\n" ); - goto remove_ctlr; - } +if (ret) +return dev_err_probe (&pdev->dev, ret,"Unable to enable APB clock.\n" ); ret =clk_prepare_enable (xspi->ref_clk);if (ret) {
@@ -869,8 +861,7 @@ static int ax_spi_probe(struct platform_device *pdev)clk_disable_unprepare (xspi->ref_clk); clk_dis_apb:clk_disable_unprepare (xspi->pclk); -remove_ctlr: -spi_controller_put (ctlr); +return ret; }
---
base-commit: 3fa5e5702a82d259897bd7e209469bc06368bf31
change-id: 20260302-axiado-b10bf8b449eb
Best regards,
Signature · 1 line
Felix Gu <[email protected]>
Mark Brown
maintainerQuoted 1 line · Felix Gu
spi: axiado: Fix double-free in
ax_spi_probe()
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-7.0
Thanks!
[1/1] spi: axiado: Fix double-free in ax_spi_probe()
https://git.kernel.org/broonie/spi/c/7fc5e2f5603c
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
Mark Brown
maintainerQuoted 8 lines · Felix Gu
ctlr is allocated using
devm_spi_alloc_host(), which automatically handles reference counting via the devm framework.Calling
spi_controller_put()manually in the probe error path is redundant and results in a double-free.[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
Thanks!
[1/1] spi: axiado: Fix double-free in ax_spi_probe()
https://git.kernel.org/broonie/misc/c/7fc5e2f5603c
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