Skip to contentSkip to conversation

skge: Make sure both ports initialize correctly

PATCH Applied Mike McCormack 3 participants 3 messages Sep 23, 2009 – Oct 1, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 skge: Make sure both ports initialize correctly

If allocation of the second ports fails, make sure that hw->ports
is not 2 otherwise we'll crash trying to access the second port.

This fix is copied from a similar fix in the sky2 driver (ca519274...), but is untested, as I don't have a skge card.

---
 drivers/net/skge.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
drivers/net/skge.c +6 -3
index 62e852e..21b816f 100644
@@ -3982,14 +3982,17 @@ static int __devinit skge_probe(struct pci_dev *pdev,
 	}
 	skge_show_addr(dev);
 
-	if (hw->ports > 1 && (dev1 = skge_devinit(hw, 1, using_dac))) {
-		if (register_netdev(dev1) == 0)
+	if (hw->ports > 1) {
+		dev1 = skge_devinit(hw, 1, using_dac);
+		if (dev1 && register_netdev(dev1) == 0)
 			skge_show_addr(dev1);
 		else {
 			/* Failure to register second port need not be fatal */
 			dev_warn(&pdev->dev, "register of second port failed\n");
 			hw->dev[1] = NULL;
-			free_netdev(dev1);
+			hw->ports = 1;
+			if (dev1)
+				free_netdev(dev1);
 		}
 	}
 	pci_set_drvdata(pdev, hw);
Signature · 1 line
1.5.6.5
Acked-by on v1 1/1
#1 lore raw
Quoted 26 lines · On Wed, 23 Sep 2009 22:50:36 +0900 Mike McCormack <[email protected]> wrote:

If allocation of the second ports fails, make sure that hw->ports
is not 2 otherwise we'll crash trying to access the second port.

This fix is copied from a similar fix in the sky2 driver (ca519274...), but is untested, as I don't have a skge card.

---
 drivers/net/skge.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
drivers/net/skge.c +3 -2
index 62e852e..21b816f 100644
@@ -3982,14 +3982,17 @@ static int __devinit skge_probe(struct pci_dev *pdev,
 	}
 	skge_show_addr(dev);
 
-	if (hw->ports > 1 && (dev1 = skge_devinit(hw, 1, using_dac))) {
-		if (register_netdev(dev1) == 0)
+	if (hw->ports > 1) {
+		dev1 = skge_devinit(hw, 1, using_dac);
+		if (dev1 && register_netdev(dev1) == 0)
 			skge_show_addr(dev1);
 		else {

drivers/net/skge.c static int __devinit skge_probe(struct pci_dev *pdev, · line 3998

Quoted 10 lines
drivers/net/skge.c +3 -1
 			/* Failure to register second port need not be fatal */
 			dev_warn(&pdev->dev, "register of second port failed\n");
 			hw->dev[1] = NULL;
-			free_netdev(dev1);
+			hw->ports = 1;
+			if (dev1)
+				free_netdev(dev1);
 		}
 	}
 	pci_set_drvdata(pdev, hw);

Looks good.

maintainer Applied
#2 lore raw

From: Stephen Hemminger <[email protected]>
Date: Wed, 30 Sep 2009 17:28:21 -0700

Quoted 10 lines
Quoted 7 lines · On Wed, 23 Sep 2009 22:50:36 +0900 Mike McCormack <[email protected]> wrote:

If allocation of the second ports fails, make sure that hw->ports
is not 2 otherwise we'll crash trying to access the second port.

This fix is copied from a similar fix in the sky2 driver (ca519274...), but is untested, as I don't have a skge card.

...

Quoted 1 line

Applied.