mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Petko Manolov <petkan@nucleusys.com>
To: Roel Kluin <roel.kluin@gmail.com>
Cc: Petko Manolov <petkan@users.sourceforge.net>,
	linux-usb@vger.kernel.org, netdev@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] usbnet: test off by one
Date: Tue, 29 Dec 2009 15:13:28 +0200 (EET)	[thread overview]
Message-ID: <alpine.DEB.2.00.0912291504520.2335@fry.nucleusys.com> (raw)
In-Reply-To: <4B37D000.6070009@gmail.com>

 	Hey Roel,

MII_TIMEOUT is a number i made up myself, reasonably small so the driver 
won't sit there forever, but higher than 2.  While testing the gadget i 
discovered that reading MII registers sometimes require more than one 
attempt.

Technically you're right.  In practice it doesn't matter much.  Hitting 
the boundary condition mean things are already out of hand.


 		Petko



On Sun, 27 Dec 2009, Roel Kluin wrote:

> With `while (i++ < MII_TIMEOUT)' i reaches MII_TIMEOUT + 1 after the loop
> This is probably unlikely a problem in practice.
>
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
> drivers/net/usb/rtl8150.c |    4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c
> index f14d225..fd19db0 100644
> --- a/drivers/net/usb/rtl8150.c
> +++ b/drivers/net/usb/rtl8150.c
> @@ -270,7 +270,7 @@ static int read_mii_word(rtl8150_t * dev, u8 phy, __u8 indx, u16 * reg)
> 		get_registers(dev, PHYCNT, 1, data);
> 	} while ((data[0] & PHY_GO) && (i++ < MII_TIMEOUT));
>
> -	if (i < MII_TIMEOUT) {
> +	if (i <= MII_TIMEOUT) {
> 		get_registers(dev, PHYDAT, 2, data);
> 		*reg = data[0] | (data[1] << 8);
> 		return 0;
> @@ -295,7 +295,7 @@ static int write_mii_word(rtl8150_t * dev, u8 phy, __u8 indx, u16 reg)
> 		get_registers(dev, PHYCNT, 1, data);
> 	} while ((data[0] & PHY_GO) && (i++ < MII_TIMEOUT));
>
> -	if (i < MII_TIMEOUT)
> +	if (i <= MII_TIMEOUT)
> 		return 0;
> 	else
> 		return 1;
>

  reply	other threads:[~2009-12-29 13:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-27 21:22 Roel Kluin
2009-12-29 13:13 ` Petko Manolov [this message]
2010-01-04  5:43 ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.00.0912291504520.2335@fry.nucleusys.com \
    --to=petkan@nucleusys.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=petkan@users.sourceforge.net \
    --cc=roel.kluin@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®