linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi: tegra20-sflash: Fix signedness bug in tegra_sflash_probe
@ 2023-07-15  9:53 Zhang Shurong
  2023-07-17  7:30 ` Thierry Reding
  0 siblings, 1 reply; 2+ messages in thread
From: Zhang Shurong @ 2023-07-15  9:53 UTC (permalink / raw)
  To: ldewangan
  Cc: broonie, thierry.reding, jonathanh, p.zabel, linux-spi,
	linux-tegra, linux-kernel, Zhang Shurong

The "tsd->irq" variable is unsigned so this error handling
code will not work.

Fix this by adding error handling statement

Fixes: 8528547bcc33 ("spi: tegra: add spi driver for sflash controller")
Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
---
 drivers/spi/spi-tegra20-sflash.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-tegra20-sflash.c b/drivers/spi/spi-tegra20-sflash.c
index 4286310628a2..4c18337de813 100644
--- a/drivers/spi/spi-tegra20-sflash.c
+++ b/drivers/spi/spi-tegra20-sflash.c
@@ -455,7 +455,11 @@ static int tegra_sflash_probe(struct platform_device *pdev)
 		goto exit_free_master;
 	}
 
-	tsd->irq = platform_get_irq(pdev, 0);
+	ret = platform_get_irq(pdev, 0);
+	if (ret < 0)
+		goto exit_free_master;
+
+	tsd->irq = ret;
 	ret = request_irq(tsd->irq, tegra_sflash_isr, 0,
 			dev_name(&pdev->dev), tsd);
 	if (ret < 0) {
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] spi: tegra20-sflash: Fix signedness bug in tegra_sflash_probe
  2023-07-15  9:53 [PATCH] spi: tegra20-sflash: Fix signedness bug in tegra_sflash_probe Zhang Shurong
@ 2023-07-17  7:30 ` Thierry Reding
  0 siblings, 0 replies; 2+ messages in thread
From: Thierry Reding @ 2023-07-17  7:30 UTC (permalink / raw)
  To: Zhang Shurong
  Cc: ldewangan, broonie, jonathanh, p.zabel, linux-spi, linux-tegra,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1353 bytes --]

On Sat, Jul 15, 2023 at 05:53:56PM +0800, Zhang Shurong wrote:
> The "tsd->irq" variable is unsigned so this error handling
> code will not work.
> 
> Fix this by adding error handling statement

This doesn't really make sense. First you say that the error handling
will not work and then you say you fix that by adding error handling.

So the bug here is that there is no error checking in the first place,
so you should probably reword that commit message.

Thierry

> 
> Fixes: 8528547bcc33 ("spi: tegra: add spi driver for sflash controller")
> Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
> ---
>  drivers/spi/spi-tegra20-sflash.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/spi/spi-tegra20-sflash.c b/drivers/spi/spi-tegra20-sflash.c
> index 4286310628a2..4c18337de813 100644
> --- a/drivers/spi/spi-tegra20-sflash.c
> +++ b/drivers/spi/spi-tegra20-sflash.c
> @@ -455,7 +455,11 @@ static int tegra_sflash_probe(struct platform_device *pdev)
>  		goto exit_free_master;
>  	}
>  
> -	tsd->irq = platform_get_irq(pdev, 0);
> +	ret = platform_get_irq(pdev, 0);
> +	if (ret < 0)
> +		goto exit_free_master;
> +
> +	tsd->irq = ret;
>  	ret = request_irq(tsd->irq, tegra_sflash_isr, 0,
>  			dev_name(&pdev->dev), tsd);
>  	if (ret < 0) {
> -- 
> 2.30.2
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-07-17  7:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-15  9:53 [PATCH] spi: tegra20-sflash: Fix signedness bug in tegra_sflash_probe Zhang Shurong
2023-07-17  7:30 ` Thierry Reding

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).