Skip to contentSkip to conversation

decnet: handle a failure in neigh_parms_alloc

PATCH In review Eric W. Biederman 3 participants 6 messages Jan 24, 2007 – Jan 25, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 decnet: handle a failure in neigh_parms_alloc

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.

---
 net/decnet/dn_dev.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
net/decnet/dn_dev.c +5 -0
index 324eb47..f6a2b2a 100644
@@ -1149,6 +1149,11 @@ struct dn_dev *dn_dev_create(struct net_device *dev, int *err)
 	}
 
 	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;
+	}
 
 	dn_dev_sysctl_register(dev, &dn_db->parms);
 
Signature · 1 line
1.4.4.1.g278f
maintainer
#1 lore raw

From: [email protected] (Eric W. Biederman)
Date: Wed, 24 Jan 2007 13:09:40 -0700

Quoted 7 lines

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.

I don't think this one is correct.

During failure cleanup you also have to invoke the neighbour parms ->down() operation if present, else you leave multicast entries on the ethernet device for example.

maintainer
#2 lore raw

From: David Miller <[email protected]>
Date: Wed, 24 Jan 2007 14:45:11 -0800 (PST)

Quoted 9 lines

From: [email protected] (Eric W. Biederman)
Date: Wed, 24 Jan 2007 13:09:40 -0700

Quoted 6 lines

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.

Quoted 7 lines
Quoted 1 line

I don't think this one is correct.

During failure cleanup you also have to invoke the neighbour parms ->down() operation if present, else you leave multicast entries on the ethernet device for example.

BTW, it occurs to me that a good way to handle this might be to try and do the neigh_parms_alloc() before running the ->up() method.

#3 lore raw

PATCH 1/1 net: decnet handle a failure in neigh_parms_alloc (take 2)

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.

---
 net/decnet/dn_dev.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
net/decnet/dn_dev.c +9 -2
index 324eb47..913e25a 100644
@@ -1140,16 +1140,23 @@ struct dn_dev *dn_dev_create(struct net_device *dev, int *err)
 	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);
Signature · 1 line
1.4.4.1.g278f
Acked-by on v1 1/1
#4 lore raw

Re: [PATCH] net: decnet handle a failure in neigh_parms_alloc (take 2)

Hi,

Quoted 7 lines · Eric W. Biederman

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.

Also you should cc Patrick as he is now the maintainer,

Steve.

Quoted 37 lines
---
 net/decnet/dn_dev.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
net/decnet/dn_dev.c +9 -2
index 324eb47..913e25a 100644
@@ -1140,16 +1140,23 @@ struct dn_dev *dn_dev_create(struct net_device *dev, int *err)
 	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);
Signature · 1 line
1.4.4.1.g278f
maintainer Applied
#5 lore raw

Re: [PATCH] net: decnet handle a failure in neigh_parms_alloc (take 2)

From: Steven Whitehouse <[email protected]>
Date: Thu, 25 Jan 2007 11:43:18 +0000

Quoted 11 lines

Hi,

Quoted 7 lines · Eric W. Biederman

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.

Applied, thanks everyone.

Quoted 1 line

Also you should cc Patrick as he is now the maintainer,

Yep, would be a good idea in the future.