* [PATCH] spi: armada-3700: fix unsigned compare than zero on irq
@ 2016-12-13 10:28 ` Colin King
0 siblings, 0 replies; 9+ messages in thread
From: Colin King @ 2016-12-13 10:28 UTC (permalink / raw)
To: Romain Perier, Mark Brown, linux-spi; +Cc: linux-kernel
From: Colin Ian King <colin.king@canonical.com>
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@canonical.com>
---
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
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH] spi: armada-3700: fix unsigned compare than zero on irq
@ 2016-12-13 10:28 ` Colin King
0 siblings, 0 replies; 9+ 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] 9+ messages in thread
* Re: [PATCH] spi: armada-3700: fix unsigned compare than zero on irq
@ 2016-12-13 10:55 ` Romain Perier
0 siblings, 0 replies; 9+ messages in thread
From: Romain Perier @ 2016-12-13 10:55 UTC (permalink / raw)
To: Colin King, Mark Brown, linux-spi; +Cc: linux-kernel
Hello,
Le 13/12/2016 à 11:28, Colin King a écrit :
> From: Colin Ian King <colin.king@canonical.com>
>
> 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@canonical.com>
> ---
> 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);
>
>
Why don't you change only the type of "irq" in struct a3700_spi ?
Thanks,
Romain
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] spi: armada-3700: fix unsigned compare than zero on irq
@ 2016-12-13 10:55 ` Romain Perier
0 siblings, 0 replies; 9+ messages in thread
From: Romain Perier @ 2016-12-13 10:55 UTC (permalink / raw)
To: Colin King, Mark Brown, linux-spi-u79uwXL29TY76Z2rM5mHXA
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA
Hello,
Le 13/12/2016 à 11:28, Colin King a écrit :
> 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);
>
>
Why don't you change only the type of "irq" in struct a3700_spi ?
Thanks,
Romain
--
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 [flat|nested] 9+ messages in thread
* Re: [PATCH] spi: armada-3700: fix unsigned compare than zero on irq
@ 2016-12-13 11:01 ` Colin Ian King
0 siblings, 0 replies; 9+ messages in thread
From: Colin Ian King @ 2016-12-13 11:01 UTC (permalink / raw)
To: Romain Perier, Mark Brown, linux-spi; +Cc: linux-kernel
On 13/12/16 10:55, Romain Perier wrote:
> Hello,
>
> Le 13/12/2016 à 11:28, Colin King a écrit :
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> 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@canonical.com>
>> ---
>> 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);
>>
>>
>
> Why don't you change only the type of "irq" in struct a3700_spi ?
>
> Thanks,
> Romain
..because I've observed that a lot of driver seems to use a unsigned int
for the irq in their driver specific structs and I also didn't want to
modify this to an int in case it some subtle signed/unsigned logic
somewhere else that I was not aware of. Just seemed like the least risky
fix to me.
Colin
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] spi: armada-3700: fix unsigned compare than zero on irq
@ 2016-12-13 11:01 ` Colin Ian King
0 siblings, 0 replies; 9+ messages in thread
From: Colin Ian King @ 2016-12-13 11:01 UTC (permalink / raw)
To: Romain Perier, Mark Brown, linux-spi-u79uwXL29TY76Z2rM5mHXA
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA
On 13/12/16 10:55, Romain Perier wrote:
> Hello,
>
> Le 13/12/2016 à 11:28, Colin King a écrit :
>> 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);
>>
>>
>
> Why don't you change only the type of "irq" in struct a3700_spi ?
>
> Thanks,
> Romain
..because I've observed that a lot of driver seems to use a unsigned int
for the irq in their driver specific structs and I also didn't want to
modify this to an int in case it some subtle signed/unsigned logic
somewhere else that I was not aware of. Just seemed like the least risky
fix to me.
Colin
--
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 [flat|nested] 9+ messages in thread
* Re: [PATCH] spi: armada-3700: fix unsigned compare than zero on irq
@ 2016-12-13 11:02 ` Romain Perier
0 siblings, 0 replies; 9+ messages in thread
From: Romain Perier @ 2016-12-13 11:02 UTC (permalink / raw)
To: Colin King, Mark Brown, linux-spi; +Cc: linux-kernel
Hello,
Le 13/12/2016 à 11:55, Romain Perier a écrit :
>>
>
> Why don't you change only the type of "irq" in struct a3700_spi ?
>
> Thanks,
> Romain
In fact, it cannot work with devmem_request_irq/request_irq which
require an unsigned int as second argument... So it's okay for me.
Acked-by: Romain Perier <romain.perier@free-electrons.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] spi: armada-3700: fix unsigned compare than zero on irq
@ 2016-12-13 11:02 ` Romain Perier
0 siblings, 0 replies; 9+ messages in thread
From: Romain Perier @ 2016-12-13 11:02 UTC (permalink / raw)
To: Colin King, Mark Brown, linux-spi-u79uwXL29TY76Z2rM5mHXA
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA
Hello,
Le 13/12/2016 à 11:55, Romain Perier a écrit :
>>
>
> Why don't you change only the type of "irq" in struct a3700_spi ?
>
> Thanks,
> Romain
In fact, it cannot work with devmem_request_irq/request_irq which
require an unsigned int as second argument... So it's okay for me.
Acked-by: Romain Perier <romain.perier-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
--
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 [flat|nested] 9+ messages in thread
* Applied "spi: armada-3700: fix unsigned compare than zero on irq" to the spi tree
2016-12-13 10:28 ` Colin King
(?)
(?)
@ 2016-12-14 18:03 ` Mark Brown
-1 siblings, 0 replies; 9+ messages in thread
From: Mark Brown @ 2016-12-14 18:03 UTC (permalink / raw)
To: Colin Ian King
Cc: Romain Perier, Mark Brown, Romain Perier, Mark Brown, linux-spi,
linux-kernel
The patch
spi: armada-3700: fix unsigned compare than zero on irq
has been applied to the spi tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
>From f6f0083cca66e673cca6fa26b52b107b5570081d Mon Sep 17 00:00:00 2001
From: Colin Ian King <colin.king@canonical.com>
Date: Tue, 13 Dec 2016 10:28:12 +0000
Subject: [PATCH] spi: armada-3700: fix unsigned compare than zero on irq
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@canonical.com>
Acked-by: Romain Perier <romain.perier@free-electrons.com>
Signed-off-by: Mark Brown <broonie@kernel.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 e89da0af45d2..4e921782652f 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.11.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2016-12-14 18:04 UTC | newest]
Thread overview: 9+ 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
2016-12-13 10:28 ` Colin King
2016-12-13 10:55 ` Romain Perier
2016-12-13 10:55 ` Romain Perier
2016-12-13 11:01 ` Colin Ian King
2016-12-13 11:01 ` Colin Ian King
2016-12-13 11:02 ` Romain Perier
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 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.