linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi: atmel: fix incorrect comparison
@ 2014-05-06 15:44 Alexandre Belloni
  2014-05-06 15:57 ` Nicolas Ferre
  2014-05-07 19:50 ` Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Alexandre Belloni @ 2014-05-06 15:44 UTC (permalink / raw)
  To: linux-arm-kernel

Found using smatch:
drivers/spi/spi-atmel.c:878 atmel_spi_pump_pio_data() warn: unsigned
'as->current_remaining_bytes' is never less than zero.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/spi/spi-atmel.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
index 079e6b1b0cdb..39417fd8462f 100644
--- a/drivers/spi/spi-atmel.c
+++ b/drivers/spi/spi-atmel.c
@@ -874,8 +874,9 @@ atmel_spi_pump_pio_data(struct atmel_spi *as, struct spi_transfer *xfer)
 		spi_readl(as, RDR);
 	}
 	if (xfer->bits_per_word > 8) {
-		as->current_remaining_bytes -= 2;
-		if (as->current_remaining_bytes < 0)
+		if (as->current_remaining_bytes > 2)
+			as->current_remaining_bytes -= 2;
+		else
 			as->current_remaining_bytes = 0;
 	} else {
 		as->current_remaining_bytes--;
-- 
1.9.1

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

* [PATCH] spi: atmel: fix incorrect comparison
  2014-05-06 15:44 [PATCH] spi: atmel: fix incorrect comparison Alexandre Belloni
@ 2014-05-06 15:57 ` Nicolas Ferre
  2014-05-07 19:50 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Nicolas Ferre @ 2014-05-06 15:57 UTC (permalink / raw)
  To: linux-arm-kernel

On 06/05/2014 17:44, Alexandre Belloni :
> Found using smatch:
> drivers/spi/spi-atmel.c:878 atmel_spi_pump_pio_data() warn: unsigned
> 'as->current_remaining_bytes' is never less than zero.
> 
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

Yes as the variable is declared as unsigned:

Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>


> ---
>  drivers/spi/spi-atmel.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
> index 079e6b1b0cdb..39417fd8462f 100644
> --- a/drivers/spi/spi-atmel.c
> +++ b/drivers/spi/spi-atmel.c
> @@ -874,8 +874,9 @@ atmel_spi_pump_pio_data(struct atmel_spi *as, struct spi_transfer *xfer)
>  		spi_readl(as, RDR);
>  	}
>  	if (xfer->bits_per_word > 8) {
> -		as->current_remaining_bytes -= 2;
> -		if (as->current_remaining_bytes < 0)
> +		if (as->current_remaining_bytes > 2)
> +			as->current_remaining_bytes -= 2;
> +		else
>  			as->current_remaining_bytes = 0;
>  	} else {
>  		as->current_remaining_bytes--;
> 


-- 
Nicolas Ferre

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

* [PATCH] spi: atmel: fix incorrect comparison
  2014-05-06 15:44 [PATCH] spi: atmel: fix incorrect comparison Alexandre Belloni
  2014-05-06 15:57 ` Nicolas Ferre
@ 2014-05-07 19:50 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2014-05-07 19:50 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, May 06, 2014 at 05:44:41PM +0200, Alexandre Belloni wrote:
> Found using smatch:
> drivers/spi/spi-atmel.c:878 atmel_spi_pump_pio_data() warn: unsigned
> 'as->current_remaining_bytes' is never less than zero.

Applied, thanks.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140507/48f1521b/attachment.sig>

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

end of thread, other threads:[~2014-05-07 19:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-06 15:44 [PATCH] spi: atmel: fix incorrect comparison Alexandre Belloni
2014-05-06 15:57 ` Nicolas Ferre
2014-05-07 19:50 ` 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).