netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pasemi_mac: mac_to_intf() error not noticed
@ 2009-04-23 17:44 Roel Kluin
  2009-04-23 17:56 ` Olof Johansson
  0 siblings, 1 reply; 5+ messages in thread
From: Roel Kluin @ 2009-04-23 17:44 UTC (permalink / raw)
  To: Olof Johansson, netdev, Andrew Morton

mac_to_intf() can return -1 when no device or function was found, but when
mac->dma_if is unsigned. The error wasn't noticed.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
diff --git a/drivers/net/pasemi_mac.c b/drivers/net/pasemi_mac.c
index 5eeb5a8..1857974 100644
--- a/drivers/net/pasemi_mac.c
+++ b/drivers/net/pasemi_mac.c
@@ -1798,12 +1798,13 @@ pasemi_mac_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	}
 	memcpy(dev->dev_addr, mac->mac_addr, sizeof(mac->mac_addr));
 
-	mac->dma_if = mac_to_intf(mac);
-	if (mac->dma_if < 0) {
+	err = mac_to_intf(mac);
+	if (err < 0) {
 		dev_err(&mac->pdev->dev, "Can't map DMA interface\n");
 		err = -ENODEV;
 		goto out;
 	}
+	mac->dma_if = err;
 
 	switch (pdev->device) {
 	case 0xa005:

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

* Re: [PATCH] pasemi_mac: mac_to_intf() error not noticed
  2009-04-23 17:44 [PATCH] pasemi_mac: mac_to_intf() error not noticed Roel Kluin
@ 2009-04-23 17:56 ` Olof Johansson
  2009-04-23 18:53   ` Roel Kluin
  0 siblings, 1 reply; 5+ messages in thread
From: Olof Johansson @ 2009-04-23 17:56 UTC (permalink / raw)
  To: Roel Kluin; +Cc: netdev, Andrew Morton

On Thu, Apr 23, 2009 at 07:44:09PM +0200, Roel Kluin wrote:
> mac_to_intf() can return -1 when no device or function was found, but when
> mac->dma_if is unsigned. The error wasn't noticed.

This can in practice never happen which is likely why it went
unnoticed.

I object to the usage of err in the way you use it, it's completely
counterintuitive to name a variable that will hold valid data to 'err'.

So, define a new variable with an appropriate name, please.


-Olof


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

* Re: [PATCH] pasemi_mac: mac_to_intf() error not noticed
  2009-04-23 17:56 ` Olof Johansson
@ 2009-04-23 18:53   ` Roel Kluin
  2009-04-23 19:54     ` Olof Johansson
  0 siblings, 1 reply; 5+ messages in thread
From: Roel Kluin @ 2009-04-23 18:53 UTC (permalink / raw)
  To: Olof Johansson; +Cc: netdev, Andrew Morton

Olof Johansson wrote:
> On Thu, Apr 23, 2009 at 07:44:09PM +0200, Roel Kluin wrote:
> This can in practice never happen which is likely why it went
> unnoticed.

> define a new variable with an appropriate name, please.

Ok, how's this?
--------------------------->8-------------8<------------------------------
mac_to_intf() can return -1 when no device or function is found, but when
mac->dma_if is unsigned. The error wasn't noticed.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
diff --git a/drivers/net/pasemi_mac.c b/drivers/net/pasemi_mac.c
index 5eeb5a8..1e8f396 100644
--- a/drivers/net/pasemi_mac.c
+++ b/drivers/net/pasemi_mac.c
@@ -1740,7 +1740,7 @@ pasemi_mac_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
 	struct net_device *dev;
 	struct pasemi_mac *mac;
-	int err;
+	int err, ret;
 
 	err = pci_enable_device(pdev);
 	if (err)
@@ -1798,12 +1798,13 @@ pasemi_mac_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	}
 	memcpy(dev->dev_addr, mac->mac_addr, sizeof(mac->mac_addr));
 
-	mac->dma_if = mac_to_intf(mac);
-	if (mac->dma_if < 0) {
+	ret = mac_to_intf(mac);
+	if (ret < 0) {
 		dev_err(&mac->pdev->dev, "Can't map DMA interface\n");
 		err = -ENODEV;
 		goto out;
 	}
+	mac->dma_if = ret;
 
 	switch (pdev->device) {
 	case 0xa005:

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

* Re: [PATCH] pasemi_mac: mac_to_intf() error not noticed
  2009-04-23 18:53   ` Roel Kluin
@ 2009-04-23 19:54     ` Olof Johansson
  2009-04-27 10:21       ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Olof Johansson @ 2009-04-23 19:54 UTC (permalink / raw)
  To: Roel Kluin; +Cc: netdev, Andrew Morton

On Thu, Apr 23, 2009 at 08:53:20PM +0200, Roel Kluin wrote:
> Olof Johansson wrote:
> > On Thu, Apr 23, 2009 at 07:44:09PM +0200, Roel Kluin wrote:
> > This can in practice never happen which is likely why it went
> > unnoticed.
> 
> > define a new variable with an appropriate name, please.
> 
> Ok, how's this?

Good, but you might have to repost without the email trail above the
patch description. Normally putting it under the signed-off-by line
with three dashes between will make sure it doesn't get picked up by
the git tools.


Anyway, that's all up to Dave, if you end up reposting feel free to add:

> --------------------------->8-------------8<------------------------------
> mac_to_intf() can return -1 when no device or function is found, but when
> mac->dma_if is unsigned. The error wasn't noticed.
> 
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>

Acked-by: Olof Johansson <olof@lixom.net>


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

* Re: [PATCH] pasemi_mac: mac_to_intf() error not noticed
  2009-04-23 19:54     ` Olof Johansson
@ 2009-04-27 10:21       ` David Miller
  0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2009-04-27 10:21 UTC (permalink / raw)
  To: olof; +Cc: roel.kluin, netdev, akpm

From: Olof Johansson <olof@lixom.net>
Date: Thu, 23 Apr 2009 14:54:03 -0500

> Anyway, that's all up to Dave, if you end up reposting feel free to add:
 ...
> Acked-by: Olof Johansson <olof@lixom.net>

Patch applied to net-next-2.6

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

end of thread, other threads:[~2009-04-27 10:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-23 17:44 [PATCH] pasemi_mac: mac_to_intf() error not noticed Roel Kluin
2009-04-23 17:56 ` Olof Johansson
2009-04-23 18:53   ` Roel Kluin
2009-04-23 19:54     ` Olof Johansson
2009-04-27 10:21       ` David Miller

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).