[patch 47/59] DECNET: Handle a failure in neigh_parms_alloc (take 2)

Chris Wright
2007-02-03T02:43:56Z

[-- Attachment #1: decnet-handle-a-failure-in-neigh_parms_alloc.patch --]
[-- Type: text/plain, Size: 1338 bytes --]

-stable review patch. If anyone has any objections, please let us know.
------------------

From: Eric W. Biederman <ebiederm@xmission.com>

While enhancing the neighbour code to handle multiple network
namespaces I noticed that decnet is assuming neigh_parms_alloc
will allways succeed, which is clearly wrong. So handle the
failure.

Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Acked-by: Steven Whitehouse <steve@chygwyn.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
---
net/decnet/dn_dev.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

--- linux-2.6.19.2.orig/net/decnet/dn_dev.c
+++ linux-2.6.19.2/net/decnet/dn_dev.c
@@ -1116,16 +1116,23 @@ struct dn_dev *dn_dev_create(struct net_
init_timer(&dn_db->timer);

dn_db->uptime = jiffies;
+
+ dn_db->neigh_parms = neigh_parms_alloc(dev, &dn_neigh_table);
+ if (!dn_db->neigh_parms) {
+ dev->dn_ptr = NULL;
+ kfree(dn_db);
+ return NULL;
+ }
+
if (dn_db->parms.up) {
if (dn_db->parms.up(dev) < 0) {
+ neigh_parms_release(&dn_neigh_table, dn_db->neigh_parms);
dev->dn_ptr = NULL;
kfree(dn_db);
return NULL;
}
}

- dn_db->neigh_parms = neigh_parms_alloc(dev, &dn_neigh_table);
-
dn_dev_sysctl_register(dev, &dn_db->parms);

dn_dev_set_timer(dev);

--