Netdev List
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: "David S. Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org, Patrick McHardy <kaber@trash.net>,
	Herbert Xu <herbert@gondor.apana.org.au>
Subject: [PATCH 1/6] [NET]: Call uninit if necessary in register_netdevice
Date: Thu, 26 Jul 2007 17:09:08 +0800	[thread overview]
Message-ID: <E1IDzLI-00009i-00@gondolin.me.apana.org.au> (raw)
In-Reply-To: 20070726090725.GA510@gondor.apana.org.au

[NET]: Call uninit if necessary in register_netdevice

This patch makes register_netdevice call dev->uninit if the regsitration
fails after dev->init has completed successfully.  Very few drivers use
the init/uninit calls but at least one (drivers/net/wan/sealevel.c) may
leak without this change.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---

 net/core/dev.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index ee40355..a284c9b 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3333,7 +3333,7 @@ int register_netdevice(struct net_device *dev)
 
 	if (!dev_valid_name(dev->name)) {
 		ret = -EINVAL;
-		goto out;
+		goto err_uninit;
 	}
 
 	dev->ifindex = dev_new_index();
@@ -3347,7 +3347,7 @@ int register_netdevice(struct net_device *dev)
 			= hlist_entry(p, struct net_device, name_hlist);
 		if (!strncmp(d->name, dev->name, IFNAMSIZ)) {
 			ret = -EEXIST;
-			goto out;
+			goto err_uninit;
 		}
 	}
 
@@ -3407,7 +3407,7 @@ int register_netdevice(struct net_device *dev)
 
 	ret = netdev_register_sysfs(dev);
 	if (ret)
-		goto out;
+		goto err_uninit;
 	dev->reg_state = NETREG_REGISTERED;
 
 	/*
@@ -3432,6 +3432,11 @@ int register_netdevice(struct net_device *dev)
 
 out:
 	return ret;
+
+err_uninit:
+	if (dev->uninit)
+		dev->uninit(dev);
+	goto out;
 }
 
 /**

  reply	other threads:[~2007-07-26  9:09 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-26  9:07 [0/6] Allow registration/change name notifications to fail Herbert Xu
2007-07-26  9:09 ` Herbert Xu [this message]
2007-07-30 23:29   ` [PATCH 1/6] [NET]: Call uninit if necessary in register_netdevice David Miller
2007-07-26  9:09 ` [PATCH 2/6] [NET]: Take dev_base_lock when moving device name hash list entry Herbert Xu
2007-07-30 23:36   ` David Miller
2007-07-26  9:09 ` [PATCH 3/6] [NET] loopback: Panic if registration fails Herbert Xu
2007-07-30 23:38   ` David Miller
2007-07-26  9:09 ` [PATCH 4/6] [NET]: Allow netdev REGISTER/CHANGENAME events to fail Herbert Xu
2007-07-31  0:03   ` David Miller
2007-07-26  9:09 ` [PATCH 5/6] [IPV4/IPV6]: Fail registration if inet device construction fails Herbert Xu
2007-07-31  0:05   ` David Miller
2007-07-26  9:09 ` [PATCH 6/6] [IPV6]: Remove circular dependency on if_inet6.h Herbert Xu
2007-07-31  0:06   ` David Miller
2007-07-26 10:37 ` [0/6] Allow registration/change name notifications to fail Stephen Hemminger
2007-07-26 11:03   ` Herbert Xu

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=E1IDzLI-00009i-00@gondolin.me.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=davem@davemloft.net \
    --cc=kaber@trash.net \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox