linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi: armada-3700: fix unsigned compare than zero on irq
@ 2016-12-13 10:28 Colin King
       [not found] ` <20161213102812.9029-1-colin.king-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
  2016-12-14 18:03 ` Applied "spi: armada-3700: fix unsigned compare than zero on irq" to the spi tree Mark Brown
  0 siblings, 2 replies; 5+ messages in thread
From: Colin King @ 2016-12-13 10:28 UTC (permalink / raw)
  To: Romain Perier, Mark Brown, linux-spi-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA

From: Colin Ian King <colin.king-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>

spi->irq is an unsigned integer hence the check if status is less than
zero has no effect.  Fix this by replacing spi->irq with an int irq
so the less than zero compare will correctly detect errors.

Issue found with static analysis with CoverityScan, CID1388567

Signed-off-by: Colin Ian King <colin.king-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
---
 drivers/spi/spi-armada-3700.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-armada-3700.c b/drivers/spi/spi-armada-3700.c
index e89da0a..4e92178 100644
--- a/drivers/spi/spi-armada-3700.c
+++ b/drivers/spi/spi-armada-3700.c
@@ -800,7 +800,7 @@ static int a3700_spi_probe(struct platform_device *pdev)
 	struct spi_master *master;
 	struct a3700_spi *spi;
 	u32 num_cs = 0;
-	int ret = 0;
+	int irq, ret = 0;
 
 	master = spi_alloc_master(dev, sizeof(*spi));
 	if (!master) {
@@ -846,12 +846,13 @@ static int a3700_spi_probe(struct platform_device *pdev)
 		goto error;
 	}
 
-	spi->irq = platform_get_irq(pdev, 0);
-	if (spi->irq < 0) {
-		dev_err(dev, "could not get irq: %d\n", spi->irq);
+	irq = platform_get_irq(pdev, 0);
+	if (irq < 0) {
+		dev_err(dev, "could not get irq: %d\n", irq);
 		ret = -ENXIO;
 		goto error;
 	}
+	spi->irq = irq;
 
 	init_completion(&spi->done);
 
-- 
2.10.2

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2016-12-14 18:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-13 10:28 [PATCH] spi: armada-3700: fix unsigned compare than zero on irq Colin King
     [not found] ` <20161213102812.9029-1-colin.king-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2016-12-13 10:55   ` Romain Perier
     [not found]     ` <c173347e-c93b-2652-0b10-14e85d5f96bd-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2016-12-13 11:01       ` Colin Ian King
2016-12-13 11:02       ` Romain Perier
2016-12-14 18:03 ` Applied "spi: armada-3700: fix unsigned compare than zero on irq" to the spi tree Mark Brown

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).