Re: [PATCH 1/5] sky2: handle network device allocation failure

2007-01-31 Thread Jeff Garzik

[EMAIL PROTECTED] wrote:

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 [EMAIL PROTECTED]


applied


-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/5] sky2: handle network device allocation failure

2007-01-26 Thread shemminger
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 [EMAIL PROTECTED]

--- sky2-2.6.orig/drivers/net/sky2.c2007-01-25 13:09:31.0 -0800
+++ sky2-2.6/drivers/net/sky2.c 2007-01-25 13:14:44.0 -0800
@@ -3350,7 +3350,7 @@
 static int __devinit sky2_probe(struct pci_dev *pdev,
const struct pci_device_id *ent)
 {
-   struct net_device *dev, *dev1 = NULL;
+   struct net_device *dev;
struct sky2_hw *hw;
int err, using_dac = 0;
 
@@ -3434,8 +3434,10 @@
   hw-chip_id, hw-chip_rev);
 
dev = sky2_init_netdev(hw, 0, using_dac);
-   if (!dev)
+   if (!dev) {
+   err = -ENOMEM;
goto err_out_free_pci;
+   }
 
if (!disable_msi  pci_enable_msi(pdev) == 0) {
err = sky2_test_msi(hw);
@@ -3463,13 +3465,19 @@
 
sky2_show_addr(dev);
 
-   if (hw-ports  1  (dev1 = sky2_init_netdev(hw, 1, using_dac))) {
-   if (register_netdev(dev1) == 0)
+   if (hw-ports  1) {
+   struct net_device *dev1;
+
+   dev1 = sky2_init_netdev(hw, 1, using_dac);
+   if (!dev1) {
+   printk(KERN_WARNING PFX
+  allocation of second port failed\n);
+   }
+   else if (!(err = register_netdev(dev1)))
sky2_show_addr(dev1);
else {
-   /* Failure to register second port need not be fatal */
printk(KERN_WARNING PFX
-  register of second port failed\n);
+  register of second port failed (%d)\n, err);
hw-dev[1] = NULL;
free_netdev(dev1);
}

--
Stephen Hemminger [EMAIL PROTECTED]

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html