lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sun, 8 Feb 2009 08:07:28 -0800
From:	David Brownell <david-b@...bell.net>
To:	Roel Kluin <roel.kluin@...il.com>
Cc:	spi-devel-general@...ts.sourceforge.net,
	lkml <linux-kernel@...r.kernel.org>,
	Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: pxa2xx_spi: spi_bfin5xx: limit reaches -1 rather than 0

On Sunday 08 February 2009, Roel Kluin wrote:
> vi drivers/spi/pxa2xx_spi.c +919 
> vi drivers/spi/spi_bfin5xx.c +645
> 
>         if (flush(drv_data) == 0) {
>                 dev_err(&drv_data->pdev->dev, "pump_transfers: flush failed\n");
>                 message->status = -EIO;
>                 giveback(drv_data);
>                 return;
>         }
> 
> But with a postfix decrement limit reaches -1 rather than 0.
> 
> Signed-off-by: Roel Kluin <roel.kluin@...il.com>

Acked-by: David Brownell <dbrownell@...rs.sourceforge.net>

Although, note that if the *actual* count mattered here,
the correect patch would be to test "flush() < 0)" ...
except when using a "do {...} while (--limit)" idiom.

Try the thought experiment of starting with "limit = 1";
not all of these patches of your would go through the 
loop even once.  Fortunately in all these cases, the
limit is an arbitrary "don't loop forever" thing.


> ---
>  drivers/spi/pxa2xx_spi.c  |    2 +-
>  drivers/spi/spi_bfin5xx.c |    2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c
> index d0fc4ca..3164741 100644
> --- a/drivers/spi/pxa2xx_spi.c
> +++ b/drivers/spi/pxa2xx_spi.c
> @@ -185,7 +185,7 @@ static int flush(struct driver_data *drv_data)
>  		while (read_SSSR(reg) & SSSR_RNE) {
>  			read_SSDR(reg);
>  		}
> -	} while ((read_SSSR(reg) & SSSR_BSY) && limit--);
> +	} while ((read_SSSR(reg) & SSSR_BSY) && --limit);
>  	write_SSSR(SSSR_ROR, reg);
>  
>  	return limit;
> diff --git a/drivers/spi/spi_bfin5xx.c b/drivers/spi/spi_bfin5xx.c
> index 7fea3cf..ea94567 100644
> --- a/drivers/spi/spi_bfin5xx.c
> +++ b/drivers/spi/spi_bfin5xx.c
> @@ -162,7 +162,7 @@ static int flush(struct driver_data *drv_data)
>  	unsigned long limit = loops_per_jiffy << 1;
>  
>  	/* wait for stop and clear stat */
> -	while (!(read_STAT(drv_data) & BIT_STAT_SPIF) && limit--)
> +	while (!(read_STAT(drv_data) & BIT_STAT_SPIF) && --limit)
>  		cpu_relax();
>  
>  	write_STAT(drv_data, BIT_STAT_CLR);
> 
> 


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ