public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Michael Rozhavsky <mrozhavsky@mrv.com>
To: vlan@scry.wanfear.com
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] 8021q memory leak
Date: Thu, 30 Jan 2003 20:29:36 +0200	[thread overview]
Message-ID: <20030130182936.GC3348@mike.nbase.co.il> (raw)

[-- 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));
 	}
 }
 

             reply	other threads:[~2003-01-30 18:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-30 18:29 Michael Rozhavsky [this message]
2003-01-30 19:15 ` [PATCH] 8021q memory leak Ben Greear
2003-01-31  8:25 ` David S. Miller
2003-01-31 10:58   ` Michael Rozhavsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030130182936.GC3348@mike.nbase.co.il \
    --to=mrozhavsky@mrv.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vlan@scry.wanfear.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox