diff mbox series

spi: tegra: Fix missing IRQ check in tegra_slink_probe()

Message ID tencent_73FCC06A3D1C14EE5175253C6FB46A07B709@qq.com
State Accepted
Commit eb9913b511f10968a02cfa5329a896855dd152a3
Headers show
Series spi: tegra: Fix missing IRQ check in tegra_slink_probe() | expand

Commit Message

Zhang Shurong Aug. 26, 2023, 10:02 a.m. UTC
This func misses checking for platform_get_irq()'s call and may passes the
negative error codes to request_irq(), which takes unsigned IRQ #,
causing it to fail with -EINVAL, overriding an original error code.

Fix this by stop calling request_irq() with invalid IRQ #s.

Fixes: dc4dc3605639 ("spi: tegra: add spi driver for SLINK controller")
Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
---
 drivers/spi/spi-tegra20-slink.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Helen Mae Koike Fornazier Aug. 28, 2023, 3:32 p.m. UTC | #1
On Saturday, August 26, 2023 07:02 -03, Zhang Shurong <zhang_shurong@foxmail.com> wrote:

> This func misses checking for platform_get_irq()'s call and may passes the
> negative error codes to request_irq(), which takes unsigned IRQ #,
> causing it to fail with -EINVAL, overriding an original error code.
> 
> Fix this by stop calling request_irq() with invalid IRQ #s.
> 
> Fixes: dc4dc3605639 ("spi: tegra: add spi driver for SLINK controller")
> Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>

Reviewed-by: Helen Koike <helen.koike@collabora.com>

> ---
>  drivers/spi/spi-tegra20-slink.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/spi/spi-tegra20-slink.c b/drivers/spi/spi-tegra20-slink.c
> index 4d6db6182c5e..f5cd365c913a 100644
> --- a/drivers/spi/spi-tegra20-slink.c
> +++ b/drivers/spi/spi-tegra20-slink.c
> @@ -1086,6 +1086,8 @@ static int tegra_slink_probe(struct platform_device *pdev)
>  	reset_control_deassert(tspi->rst);
>  
>  	spi_irq = platform_get_irq(pdev, 0);
> +	if (spi_irq < 0)
> +		return spi_irq;
>  	tspi->irq = spi_irq;
>  	ret = request_threaded_irq(tspi->irq, tegra_slink_isr,
>  				   tegra_slink_isr_thread, IRQF_ONESHOT,
> -- 
> 2.30.2
>
diff mbox series

Patch

diff --git a/drivers/spi/spi-tegra20-slink.c b/drivers/spi/spi-tegra20-slink.c
index 4d6db6182c5e..f5cd365c913a 100644
--- a/drivers/spi/spi-tegra20-slink.c
+++ b/drivers/spi/spi-tegra20-slink.c
@@ -1086,6 +1086,8 @@  static int tegra_slink_probe(struct platform_device *pdev)
 	reset_control_deassert(tspi->rst);
 
 	spi_irq = platform_get_irq(pdev, 0);
+	if (spi_irq < 0)
+		return spi_irq;
 	tspi->irq = spi_irq;
 	ret = request_threaded_irq(tspi->irq, tegra_slink_isr,
 				   tegra_slink_isr_thread, IRQF_ONESHOT,