[PATCH 1/2] spi: stm32-ospi: Fix reset control leak on probe error

Felix Gu posted 2 patches 4 days, 20 hours ago
[PATCH 1/2] spi: stm32-ospi: Fix reset control leak on probe error
Posted by Felix Gu 4 days, 20 hours ago
When spi_register_controller() fails after reset_control_acquire()
succeeds, the reset control is never released. This causes a resource
leak in the error path.

Add the missing reset_control_release() call in the error path.

Fixes: cf2c3eceb757 ("spi: stm32-ospi: Make usage of reset_control_acquire/release() API")
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
---
 drivers/spi/spi-stm32-ospi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-stm32-ospi.c b/drivers/spi/spi-stm32-ospi.c
index acf2d182e8b1..52997c3f7174 100644
--- a/drivers/spi/spi-stm32-ospi.c
+++ b/drivers/spi/spi-stm32-ospi.c
@@ -960,13 +960,15 @@ static int stm32_ospi_probe(struct platform_device *pdev)
 	if (ret) {
 		/* Disable ospi */
 		writel_relaxed(0, ospi->regs_base + OSPI_CR);
-		goto err_pm_resume;
+		goto err_reset_control;
 	}
 
 	pm_runtime_put_autosuspend(ospi->dev);
 
 	return 0;
 
+err_reset_control:
+	reset_control_release(ospi->rstc);
 err_pm_resume:
 	pm_runtime_put_sync_suspend(ospi->dev);
 

-- 
2.43.0
Re: [PATCH 1/2] spi: stm32-ospi: Fix reset control leak on probe error
Posted by Patrice CHOTARD 3 days, 6 hours ago

On 3/28/26 17:07, Felix Gu wrote:
> When spi_register_controller() fails after reset_control_acquire()
> succeeds, the reset control is never released. This causes a resource
> leak in the error path.
> 
> Add the missing reset_control_release() call in the error path.
> 
> Fixes: cf2c3eceb757 ("spi: stm32-ospi: Make usage of reset_control_acquire/release() API")
> Signed-off-by: Felix Gu <ustc.gu@gmail.com>
> ---
>  drivers/spi/spi-stm32-ospi.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/spi/spi-stm32-ospi.c b/drivers/spi/spi-stm32-ospi.c
> index acf2d182e8b1..52997c3f7174 100644
> --- a/drivers/spi/spi-stm32-ospi.c
> +++ b/drivers/spi/spi-stm32-ospi.c
> @@ -960,13 +960,15 @@ static int stm32_ospi_probe(struct platform_device *pdev)
>  	if (ret) {
>  		/* Disable ospi */
>  		writel_relaxed(0, ospi->regs_base + OSPI_CR);
> -		goto err_pm_resume;
> +		goto err_reset_control;
>  	}
>  
>  	pm_runtime_put_autosuspend(ospi->dev);
>  
>  	return 0;
>  
> +err_reset_control:
> +	reset_control_release(ospi->rstc);
>  err_pm_resume:
>  	pm_runtime_put_sync_suspend(ospi->dev);
>  
> 


Hi Felix

Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>

Thanks
Patrice