All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tg3: fix return value check in tg3_read_vpd()
@ 2010-12-27 17:31 David Sterba
  2010-12-27 20:19 ` Dan Carpenter
  0 siblings, 1 reply; 5+ messages in thread
From: David Sterba @ 2010-12-27 17:31 UTC (permalink / raw)
  To: mcarlson; +Cc: netdev, linux-kernel, David Sterba, Michael Chan

CC: Matt Carlson <mcarlson@broadcom.com>
CC: Michael Chan <mchan@broadcom.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
---
 drivers/net/tg3.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 30ccbb6..6f97b7b 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -12658,7 +12658,7 @@ static void __devinit tg3_read_vpd(struct tg3 *tp)
 			cnt = pci_read_vpd(tp->pdev, pos,
 					   TG3_NVM_VPD_LEN - pos,
 					   &vpd_data[pos]);
-			if (cnt == -ETIMEDOUT || -EINTR)
+			if (cnt == -ETIMEDOUT || cnt == -EINTR)
 				cnt = 0;
 			else if (cnt < 0)
 				goto out_not_found;
-- 
1.7.3.4.626.g73e7b


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

* Re: [PATCH] tg3: fix return value check in tg3_read_vpd()
  2010-12-27 17:31 [PATCH] tg3: fix return value check in tg3_read_vpd() David Sterba
@ 2010-12-27 20:19 ` Dan Carpenter
  2010-12-29 13:17   ` David Sterba
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2010-12-27 20:19 UTC (permalink / raw)
  To: David Sterba; +Cc: mcarlson, netdev, linux-kernel, Michael Chan

On Mon, Dec 27, 2010 at 06:31:34PM +0100, David Sterba wrote:
> CC: Matt Carlson <mcarlson@broadcom.com>
> CC: Michael Chan <mchan@broadcom.com>
> Signed-off-by: David Sterba <dsterba@suse.cz>
> ---

Your fix is obviously correct, but could you describe the symptoms
in your changelog instead of leaving it blank?  In the original code,
negative error values are ignored so we never goto out_not_found.  Can
pci_read_vpd() return any errors we care about besides -ENODEV?  What I
mean is, did you find this through analysing the code or did it cause a
bug at runtime?

regards,
dan carpenter


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

* Re: [PATCH] tg3: fix return value check in tg3_read_vpd()
  2010-12-27 20:19 ` Dan Carpenter
@ 2010-12-29 13:17   ` David Sterba
  2010-12-29 13:40     ` [PATCH v2] " David Sterba
  0 siblings, 1 reply; 5+ messages in thread
From: David Sterba @ 2010-12-29 13:17 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: mcarlson, netdev, linux-kernel, Michael Chan

Hi,

On Monday 27 December 2010 21:19:27 Dan Carpenter wrote:
> Your fix is obviously correct, but could you describe the symptoms
> in your changelog instead of leaving it blank?  In the original code,
> negative error values are ignored so we never goto out_not_found.  Can
> pci_read_vpd() return any errors we care about besides -ENODEV?  What I
> mean is, did you find this through analysing the code or did it cause a
> bug at runtime?

Although pci_read_vpd returns ENODEV directly, there is a call to vpd->read
function which may return other error values and is eg. set to
pci_vpd_pci22_read() :

drivers/pci/access.c::pci_vpd_pci22_read()
  may return -EINVAL or -EINTR directly
  or -ETIMEDOUT or -EINTR via pci_vpd_pci22_wait()

Yes, other negative values besides ETIMEDOUT and EINTR are ignored and after
3 attempts the pos != TG3_NVM_VPD_LEN check goes outwards. The fixed version
allows to jump out immediately. So this does not manifest itself as a 
misbehaviour at runtime. It was found by code analysis.

I'll post updated patch.

dave

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

* [PATCH v2] tg3: fix return value check in tg3_read_vpd()
  2010-12-29 13:17   ` David Sterba
@ 2010-12-29 13:40     ` David Sterba
  2010-12-31 20:31       ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: David Sterba @ 2010-12-29 13:40 UTC (permalink / raw)
  To: mcarlson; +Cc: linux-kernel, netdev, David Sterba, Michael Chan

Besides -ETIMEDOUT and -EINTR, pci_read_vpd may return other error
values like -ENODEV or -EINVAL which are ignored due to the buggy
check, but the data are not read from VPD anyway and this is checked
subsequently with at most 3 needless loop iterations. This does not
show up as a runtime bug.

CC: Matt Carlson <mcarlson@broadcom.com>
CC: Michael Chan <mchan@broadcom.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
---
 drivers/net/tg3.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 30ccbb6..6f97b7b 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -12658,7 +12658,7 @@ static void __devinit tg3_read_vpd(struct tg3 *tp)
 			cnt = pci_read_vpd(tp->pdev, pos,
 					   TG3_NVM_VPD_LEN - pos,
 					   &vpd_data[pos]);
-			if (cnt == -ETIMEDOUT || -EINTR)
+			if (cnt == -ETIMEDOUT || cnt == -EINTR)
 				cnt = 0;
 			else if (cnt < 0)
 				goto out_not_found;
-- 
1.7.4.rc0


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

* Re: [PATCH v2] tg3: fix return value check in tg3_read_vpd()
  2010-12-29 13:40     ` [PATCH v2] " David Sterba
@ 2010-12-31 20:31       ` David Miller
  0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2010-12-31 20:31 UTC (permalink / raw)
  To: dsterba; +Cc: mcarlson, linux-kernel, netdev, mchan

From: David Sterba <dsterba@suse.cz>
Date: Wed, 29 Dec 2010 14:40:31 +0100

> Besides -ETIMEDOUT and -EINTR, pci_read_vpd may return other error
> values like -ENODEV or -EINVAL which are ignored due to the buggy
> check, but the data are not read from VPD anyway and this is checked
> subsequently with at most 3 needless loop iterations. This does not
> show up as a runtime bug.
> 
> CC: Matt Carlson <mcarlson@broadcom.com>
> CC: Michael Chan <mchan@broadcom.com>
> Signed-off-by: David Sterba <dsterba@suse.cz>

Applied, thanks.

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

end of thread, other threads:[~2010-12-31 20:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-27 17:31 [PATCH] tg3: fix return value check in tg3_read_vpd() David Sterba
2010-12-27 20:19 ` Dan Carpenter
2010-12-29 13:17   ` David Sterba
2010-12-29 13:40     ` [PATCH v2] " David Sterba
2010-12-31 20:31       ` David Miller

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.