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] [day] [month] [year] [list]
Date:	Wed, 6 Jan 2010 12:14:34 +0100
From:	Jean Delvare <khali@...ux-fr.org>
To:	Roel Kluin <roel.kluin@...il.com>
Cc:	"Ben Dooks (embedded platforms)" <ben-linux@...ff.org>,
	linux-i2c@...r.kernel.org,
	Andrew Morton <akpm@...ux-foundation.org>,
	LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] i2c: test off by one in {piix4,vt596}_transaction()

On Tue, 05 Jan 2010 22:22:23 +0100, Roel Kluin wrote:
> With `while (timeout++ < MAX_TIMEOUT)' timeout reaches MAX_TIMEOUT + 1 after the loop
> This is probably unlikely to produce a problem.
> 
> Signed-off-by: Roel Kluin <roel.kluin@...il.com>
> ---
> > That's right... but I'd rather change the loops to use "++timeout" and
> > leave the conditions as is (or maybe change it to "=="). I think it's
> > easier to read that way. Would that be OK with you?
> 
> Ok,
> 
>  drivers/i2c/busses/i2c-piix4.c  |    4 ++--
>  drivers/i2c/busses/i2c-viapro.c |    4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
> index 1e245e9..e56e4b6 100644
> --- a/drivers/i2c/busses/i2c-piix4.c
> +++ b/drivers/i2c/busses/i2c-piix4.c
> @@ -324,12 +324,12 @@ static int piix4_transaction(void)
>  	else
>  		msleep(1);
>  
> -	while ((timeout++ < MAX_TIMEOUT) &&
> +	while ((++timeout < MAX_TIMEOUT) &&
>  	       ((temp = inb_p(SMBHSTSTS)) & 0x01))
>  		msleep(1);
>  
>  	/* If the SMBus is still busy, we give up */
> -	if (timeout >= MAX_TIMEOUT) {
> +	if (timeout == MAX_TIMEOUT) {
>  		dev_err(&piix4_adapter.dev, "SMBus Timeout!\n");
>  		result = -ETIMEDOUT;
>  	}
> diff --git a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c
> index e4b1543..a84a909 100644
> --- a/drivers/i2c/busses/i2c-viapro.c
> +++ b/drivers/i2c/busses/i2c-viapro.c
> @@ -165,10 +165,10 @@ static int vt596_transaction(u8 size)
>  	do {
>  		msleep(1);
>  		temp = inb_p(SMBHSTSTS);
> -	} while ((temp & 0x01) && (timeout++ < MAX_TIMEOUT));
> +	} while ((temp & 0x01) && (++timeout < MAX_TIMEOUT));
>  
>  	/* If the SMBus is still busy, we give up */
> -	if (timeout >= MAX_TIMEOUT) {
> +	if (timeout == MAX_TIMEOUT) {
>  		result = -ETIMEDOUT;
>  		dev_err(&vt596_adapter.dev, "SMBus timeout!\n");
>  	}

Applied, thanks.

-- 
Jean Delvare
--
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