All of lore.kernel.org
 help / color / mirror / Atom feed
From: shemminger@linux-foundation.org
To: Jeff Garzik <jgarzik@pobox.com>
Cc: netdev@vger.kernel.org
Subject: [PATCH 1/5] sky2: handle network device allocation failure
Date: Fri, 26 Jan 2007 11:38:36 -0800	[thread overview]
Message-ID: <20070126194004.028526000@linux-foundation.org> (raw)
In-Reply-To: 20070126193835.658962000@linux-foundation.org

[-- Attachment #1: sky2-err-allocfail.patch --]
[-- Type: text/plain, Size: 1569 bytes --]

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>

--- sky2-2.6.orig/drivers/net/sky2.c	2007-01-25 13:09:31.000000000 -0800
+++ sky2-2.6/drivers/net/sky2.c	2007-01-25 13:14:44.000000000 -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 <shemminger@linux-foundation.org>


  reply	other threads:[~2007-01-26 19:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-26 19:38 [PATCH 0/5] sky2 v1.11.1 patches shemminger
2007-01-26 19:38 ` shemminger [this message]
2007-01-31 10:03   ` [PATCH 1/5] sky2: handle network device allocation failure Jeff Garzik
2007-01-26 19:38 ` [PATCH 2/5] sky2: add Wake On Lan support shemminger
2007-01-31 10:03   ` Jeff Garzik
2007-01-26 19:38 ` [PATCH 3/5] sky2: use dev_err for error reports shemminger
2007-01-31 10:03   ` Jeff Garzik
2007-01-26 19:38 ` [PATCH 4/5] sky2: software rx/tx stats shemminger
2007-01-31 10:04   ` Jeff Garzik
2007-01-26 19:38 ` [PATCH 5/5] sky2: version 1.11.1 shemminger
2007-01-31 10:04   ` Jeff Garzik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070126194004.028526000@linux-foundation.org \
    --to=shemminger@linux-foundation.org \
    --cc=jgarzik@pobox.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.