Skip to contentSkip to conversation

8021q memory leak

PATCH In review Michael Rozhavsky 3 participants 4 messages Jan 30, 2003 – Jan 31, 2003 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 8021q memory leak

Hi,

There is a memory leak in vlan module of 2.4.20

When last vlan of the group is removed the group is unhashed but not deleted.

Attached patch fixes this memory leak and completes implementation of memory debug output.

--
Michael Rozhavsky
Senior Software Engineer
MRV International
Tel: +972 (4) 993-6248
Fax: +972 (4) 989-0564
http://www.mrv.com

net/8021q/vlan.c +7 -0
diff -u linux-2.4.20/net/8021q/vlan.c linux-2.4.20-test/net/8021q/vlan.c
@@ -171,6 +171,8 @@
 		next = *pprev;
 	}
 	*pprev = grp->next;
+	kfree (grp);
+	VLAN_MEM_DBG("vlan_group kfree, addr: %p  size: %i\n", grp, sizeof(struct vlan_group));
 }
 
 /*  Find the protocol handler.  Assumes VID < VLAN_VID_MASK.
@@ -509,6 +545,7 @@
 	 */
 	if (!grp) { /* need to add a new group */
 		grp = kmalloc(sizeof(struct vlan_group), GFP_KERNEL);
+		VLAN_MEM_DBG("vlan_group malloc, addr: %p  size: %i\n", grp, sizeof(struct vlan_group));
 		if (!grp)
 			goto out_free_newdev_priv;
 					
@@ -546,9 +583,13 @@
 
 out_free_newdev_priv:
 	kfree(new_dev->priv);
+	VLAN_MEM_DBG("new_dev->priv kfree, addr: %p  size: %i\n",
+		     new_dev->priv, sizeof(struct vlan_dev_info));
 
 out_free_newdev:
 	kfree(new_dev);
+	VLAN_MEM_DBG("net_device kfree, addr: %p  size: %i\n",
+		     new_dev, sizeof (struct net_device));
 
 out_unlock:
 	rtnl_unlock();
net/8021q/vlan_dev.c +6 -1
diff -u linux-2.4.20/net/8021q/vlan_dev.c linux-2.4.20-test/net/8021q/vlan_dev.c
@@ -171,7 +171,7 @@
 
 #ifdef VLAN_DEBUG
 		printk(VLAN_DBG "%s: dropping skb: %p because came in on wrong device, dev: %s  real_dev: %s, skb_dev: %s\n",
-			__FUNCTION__ skb, dev->name, 
+			__FUNCTION__, skb, dev->name, 
 			VLAN_DEV_INFO(skb->dev)->real_dev->name, 
 			skb->dev->name);
 #endif
@@ -783,8 +783,13 @@
 				BUG();
 
 			kfree(dev->priv);
+			VLAN_MEM_DBG("dev->priv kfree, addr: %p  size: %i\n",
+				     dev->priv, sizeof(struct vlan_dev_info));
 			dev->priv = NULL;
 		}
+		/* will be deleted by kernel */
+		VLAN_MEM_DBG("net_device kfree, addr: %p  size: %i\n",
+			     dev, sizeof (struct net_device));
 	}
 }
 
#1 lore raw
Quoted 9 lines · Michael Rozhavsky

Hi,

There is a memory leak in vlan module of 2.4.20

When last vlan of the group is removed the group is unhashed but not deleted.

Attached patch fixes this memory leak and completes implementation of memory debug output.

I believe some of the memory leaks were fixed in the -pre3 patch. I'll wander through the code to make sure that the ones you found were addressed.

Thanks,
Ben

Signature · 3 lines
Ben Greear <[email protected]>       <Ben_Greear AT excite.com>
President of Candela Technologies Inc      http://www.candelatech.com
ScryMUD:  http://scry.wanfear.com     http://scry.wanfear.com/~greear
#2 lore raw
In reply to Michael Rozhavsky
Quoted 4 lines · Michael Rozhavsky

There is a memory leak in vlan module of 2.4.20

When last vlan of the group is removed the group is unhashed but not deleted.

I think this is fixed in 2.4.21-preX already, please verify.

#3 lore raw

Hi,

Yes, you right. I've just looked in pre4 and the fix is there.

Thanks.

Quoted 8 lines · David S. Miller
Quoted 4 lines · Michael Rozhavsky

There is a memory leak in vlan module of 2.4.20

When last vlan of the group is removed the group is unhashed but not deleted.

I think this is fixed in 2.4.21-preX already, please verify.

--
Michael Rozhavsky
Senior Software Engineer
MRV International
Tel: +972 (4) 993-6248
Fax: +972 (4) 989-0564
http://www.mrv.com