* [PATCH v2] spi: tegra20: Fix missing IRQ check in tegra_slink_probe
@ 2022-01-28 16:18 Miaoqian Lin
2022-01-28 16:37 ` Dmitry Osipenko
0 siblings, 1 reply; 3+ messages in thread
From: Miaoqian Lin @ 2022-01-28 16:18 UTC (permalink / raw)
To: Laxman Dewangan, Mark Brown, Thierry Reding, Jonathan Hunter,
Dmitry Osipenko, linux-spi, linux-tegra, linux-kernel
Cc: linmq006
This func misses checking for platform_get_irq()'s call and may passes the
negative error codes to request_threaded_irq(), which takes unsigned IRQ #,
causing it to fail with -EINVAL, overriding an original error code.
Stop calling request_threaded_irq() with invalid IRQ #s.
Fixes: e4bb903fda0e ("spi: tegra20-slink: Improve runtime PM usage")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
Changes in v2:
- fix wrong func name in commit message.
---
drivers/spi/spi-tegra20-slink.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/spi/spi-tegra20-slink.c b/drivers/spi/spi-tegra20-slink.c
index 2a03739a0c60..0eea35882777 100644
--- a/drivers/spi/spi-tegra20-slink.c
+++ b/drivers/spi/spi-tegra20-slink.c
@@ -1100,6 +1100,11 @@ 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) {
+ dev_err(&pdev->dev, "Unable to request IRQ: %d\n", ret);
+ ret = spi_irq;
+ goto exit_pm_put;
+ }
tspi->irq = spi_irq;
ret = request_threaded_irq(tspi->irq, tegra_slink_isr,
tegra_slink_isr_thread, IRQF_ONESHOT,
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] spi: tegra20: Fix missing IRQ check in tegra_slink_probe
2022-01-28 16:18 [PATCH v2] spi: tegra20: Fix missing IRQ check in tegra_slink_probe Miaoqian Lin
@ 2022-01-28 16:37 ` Dmitry Osipenko
2022-01-28 16:47 ` [PATCH v3] " Miaoqian Lin
0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Osipenko @ 2022-01-28 16:37 UTC (permalink / raw)
To: Miaoqian Lin, Laxman Dewangan, Mark Brown, Thierry Reding,
Jonathan Hunter, linux-spi, linux-tegra, linux-kernel
28.01.2022 19:18, Miaoqian Lin пишет:
> This func misses checking for platform_get_irq()'s call and may passes the
> negative error codes to request_threaded_irq(), which takes unsigned IRQ #,
> causing it to fail with -EINVAL, overriding an original error code.
> Stop calling request_threaded_irq() with invalid IRQ #s.
>
> Fixes: e4bb903fda0e ("spi: tegra20-slink: Improve runtime PM usage")
I don't see how this patch is related to e4bb903fda0e. This tag is
incorrect and should be removed.
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
> ---
> Changes in v2:
> - fix wrong func name in commit message.
> ---
> drivers/spi/spi-tegra20-slink.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/spi/spi-tegra20-slink.c b/drivers/spi/spi-tegra20-slink.c
> index 2a03739a0c60..0eea35882777 100644
> --- a/drivers/spi/spi-tegra20-slink.c
> +++ b/drivers/spi/spi-tegra20-slink.c
> @@ -1100,6 +1100,11 @@ 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) {
> + dev_err(&pdev->dev, "Unable to request IRQ: %d\n", ret);
The "ret" isn't assigned to spi_irq in the error message.
Moreover, platform_get_irq() already prints error message [1] by itself.
The duplicated message is unnecessary and should be removed.
[1]
https://elixir.bootlin.com/linux/v5.17-rc1/source/drivers/base/platform.c#L256
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v3] spi: tegra20: Fix missing IRQ check in tegra_slink_probe
2022-01-28 16:37 ` Dmitry Osipenko
@ 2022-01-28 16:47 ` Miaoqian Lin
0 siblings, 0 replies; 3+ messages in thread
From: Miaoqian Lin @ 2022-01-28 16:47 UTC (permalink / raw)
To: Laxman Dewangan, Mark Brown, Thierry Reding, Jonathan Hunter,
Stephen Warren, linux-spi, linux-tegra, linux-kernel
Cc: linmq006
This func misses checking for platform_get_irq()'s call and may passes the
negative error codes to request_threaded_irq(), which takes unsigned IRQ #,
causing it to fail with -EINVAL, overriding an original error code.
Stop calling request_threaded_irq() with invalid IRQ #s.
Fixes: dc4dc3605639 ("spi: tegra: add spi driver for SLINK controller")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
Changes in v2:
- fix wrong func name in commit message.
Changes in v3:
- fix Fixes tag info.
- remove redundant error message.
---
drivers/spi/spi-tegra20-slink.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/spi/spi-tegra20-slink.c b/drivers/spi/spi-tegra20-slink.c
index 2a03739a0c60..f8661963ecba 100644
--- a/drivers/spi/spi-tegra20-slink.c
+++ b/drivers/spi/spi-tegra20-slink.c
@@ -1100,6 +1100,10 @@ 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) {
+ ret = spi_irq;
+ goto exit_pm_put;
+ }
tspi->irq = spi_irq;
ret = request_threaded_irq(tspi->irq, tegra_slink_isr,
tegra_slink_isr_thread, IRQF_ONESHOT,
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-01-28 16:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-28 16:18 [PATCH v2] spi: tegra20: Fix missing IRQ check in tegra_slink_probe Miaoqian Lin
2022-01-28 16:37 ` Dmitry Osipenko
2022-01-28 16:47 ` [PATCH v3] " Miaoqian Lin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.