OpenVZ Forum


Home » Mailing lists » Devel » [PATCH][VLAN]: Fix egress priority mappings leak.
[PATCH][VLAN]: Fix egress priority mappings leak. [message #29062] Fri, 04 April 2008 09:44 Go to next message
Pavel Emelianov is currently offline  Pavel Emelianov
Messages: 1149
Registered: September 2006
Senior Member
These entries are allocated in vlan_dev_set_egress_priority, 
but are never released and leaks on vlan device removal.

Drop these in vlan's ->uninit callback - after the device is 
brought down and everyone is notified about it is going to
be unregistered.

Found during testing vlan netnsization patchset.

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>

---

diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 480ea90..41a76a0 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -692,6 +692,20 @@ static int vlan_dev_init(struct net_device *dev)
 	return 0;
 }
 
+static void vlan_dev_uninit(struct net_device *dev)
+{
+	struct vlan_priority_tci_mapping *pm;
+	struct vlan_dev_info *vlan = vlan_dev_info(dev);
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(vlan->egress_priority_map); i++) {
+		while ((pm = vlan->egress_priority_map[i]) != NULL) {
+			vlan->egress_priority_map[i] = pm->next;
+			kfree(pm);
+		}
+	}
+}
+
 void vlan_setup(struct net_device *dev)
 {
 	ether_setup(dev);
@@ -701,6 +715,7 @@ void vlan_setup(struct net_device *dev)
 
 	dev->change_mtu		= vlan_dev_change_mtu;
 	dev->init		= vlan_dev_init;
+	dev->uninit		= vlan_dev_uninit;
 	dev->open		= vlan_dev_open;
 	dev->stop		= vlan_dev_stop;
 	dev->set_mac_address	= vlan_dev_set_mac_address;
Re: [PATCH][VLAN]: Fix egress priority mappings leak. [message #29063 is a reply to message #29062] Fri, 04 April 2008 09:45 Go to previous messageGo to next message
Patrick McHardy is currently offline  Patrick McHardy
Messages: 107
Registered: March 2006
Senior Member
Pavel Emelyanov wrote:
> These entries are allocated in vlan_dev_set_egress_priority, 
> but are never released and leaks on vlan device removal.
> 
> Drop these in vlan's ->uninit callback - after the device is 
> brought down and everyone is notified about it is going to
> be unregistered.
> 
> Found during testing vlan netnsization patchset.
> 
> Signed-off-by: Pavel Emelyanov <xemul@openvz.org>

Good catch, thanks.

Acked-by: Patrick McHardy <kaber@trash.net>
Re: [PATCH][VLAN]: Fix egress priority mappings leak. [message #29101 is a reply to message #29063] Fri, 04 April 2008 19:45 Go to previous message
davem is currently offline  davem
Messages: 463
Registered: February 2006
Senior Member
From: Patrick McHardy <kaber@trash.net>
Date: Fri, 04 Apr 2008 11:45:58 +0200

> Pavel Emelyanov wrote:
> > These entries are allocated in vlan_dev_set_egress_priority, 
> > but are never released and leaks on vlan device removal.
> > 
> > Drop these in vlan's ->uninit callback - after the device is 
> > brought down and everyone is notified about it is going to
> > be unregistered.
> > 
> > Found during testing vlan netnsization patchset.
> > 
> > Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
> 
> Good catch, thanks.
> 
> Acked-by: Patrick McHardy <kaber@trash.net>

Applied, thanks a lot.
Previous Topic: [RFC][PATCH 1/4] Provide a new procfs interface to set next id
Next Topic: [PATCH 0/7][v2] Clone PTY namespaces
Goto Forum:
  


Current Time: Wed Jun 19 14:48:35 GMT 2024

Total time taken to generate the page: 0.03384 seconds