aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sky2.c
diff options
context:
space:
mode:
authorshemminger@linux-foundation.org <shemminger@linux-foundation.org>2007-01-26 14:38:36 -0500
committerJeff Garzik <jeff@garzik.org>2007-02-05 16:58:49 -0500
commit7f60c64bd0e7262b51faefcce5d8df9d51d84b60 (patch)
tree95e1abd4cc6fe82d6b146113eda8fa15a9c8603a /drivers/net/sky2.c
parent2bf56fe25cef2a7652f7b2ab37ac14a336c76c75 (diff)
sky2: handle network device allocation failure
If alloc_etherdev() failed, then sky2_init_netdev will return NULL, and sky2_probe would end up returning 0 instead of -ENOMEM. Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/sky2.c')
-rw-r--r--drivers/net/sky2.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index 947439167493..bf1abf034d8a 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -3339,7 +3339,7 @@ static int __devinit sky2_test_msi(struct sky2_hw *hw)
3339static int __devinit sky2_probe(struct pci_dev *pdev, 3339static int __devinit sky2_probe(struct pci_dev *pdev,
3340 const struct pci_device_id *ent) 3340 const struct pci_device_id *ent)
3341{ 3341{
3342 struct net_device *dev, *dev1 = NULL; 3342 struct net_device *dev;
3343 struct sky2_hw *hw; 3343 struct sky2_hw *hw;
3344 int err, using_dac = 0; 3344 int err, using_dac = 0;
3345 3345
@@ -3423,8 +3423,10 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
3423 hw->chip_id, hw->chip_rev); 3423 hw->chip_id, hw->chip_rev);
3424 3424
3425 dev = sky2_init_netdev(hw, 0, using_dac); 3425 dev = sky2_init_netdev(hw, 0, using_dac);
3426 if (!dev) 3426 if (!dev) {
3427 err = -ENOMEM;
3427 goto err_out_free_pci; 3428 goto err_out_free_pci;
3429 }
3428 3430
3429 if (!disable_msi && pci_enable_msi(pdev) == 0) { 3431 if (!disable_msi && pci_enable_msi(pdev) == 0) {
3430 err = sky2_test_msi(hw); 3432 err = sky2_test_msi(hw);
@@ -3452,13 +3454,19 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
3452 3454
3453 sky2_show_addr(dev); 3455 sky2_show_addr(dev);
3454 3456
3455 if (hw->ports > 1 && (dev1 = sky2_init_netdev(hw, 1, using_dac))) { 3457 if (hw->ports > 1) {
3456 if (register_netdev(dev1) == 0) 3458 struct net_device *dev1;
3459
3460 dev1 = sky2_init_netdev(hw, 1, using_dac);
3461 if (!dev1) {
3462 printk(KERN_WARNING PFX
3463 "allocation of second port failed\n");
3464 }
3465 else if (!(err = register_netdev(dev1)))
3457 sky2_show_addr(dev1); 3466 sky2_show_addr(dev1);
3458 else { 3467 else {
3459 /* Failure to register second port need not be fatal */
3460 printk(KERN_WARNING PFX 3468 printk(KERN_WARNING PFX
3461 "register of second port failed\n"); 3469 "register of second port failed (%d)\n", err);
3462 hw->dev[1] = NULL; 3470 hw->dev[1] = NULL;
3463 free_netdev(dev1); 3471 free_netdev(dev1);
3464 } 3472 }