public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] 8021q memory leak
@ 2003-01-30 18:29 Michael Rozhavsky
  2003-01-30 19:15 ` Ben Greear
  2003-01-31  8:25 ` David S. Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Michael Rozhavsky @ 2003-01-30 18:29 UTC (permalink / raw)
  To: vlan; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 366 bytes --]

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

[-- Attachment #2: vlan.diff --]
[-- Type: text/plain, Size: 1952 bytes --]

diff -u linux-2.4.20/net/8021q/vlan.c linux-2.4.20-test/net/8021q/vlan.c
--- linux-2.4.20/net/8021q/vlan.c	2002-11-29 01:53:15.000000000 +0200
+++ linux-2.4.20-test/net/8021q/vlan.c	2003-01-30 20:19:12.000000000 +0200
@@ -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();
diff -u linux-2.4.20/net/8021q/vlan_dev.c linux-2.4.20-test/net/8021q/vlan_dev.c
--- linux-2.4.20/net/8021q/vlan_dev.c	2002-11-29 01:53:15.000000000 +0200
+++ linux-2.4.20-test/net/8021q/vlan_dev.c	2003-01-30 20:06:26.000000000 +0200
@@ -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));
 	}
 }
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-01-31 10:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-30 18:29 [PATCH] 8021q memory leak Michael Rozhavsky
2003-01-30 19:15 ` Ben Greear
2003-01-31  8:25 ` David S. Miller
2003-01-31 10:58   ` Michael Rozhavsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox