All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Eli Chen" <eli@routefree.com>
To: <linux-kernel@vger.kernel.org>
Cc: <paulus@linuxcare.com.au>
Subject: [PATCH] ppp_generic.c - kfree(ppp) called twice, kernel 2.4.0
Date: Tue, 3 Jul 2001 13:50:40 -0700	[thread overview]
Message-ID: <034101c10401$feec9340$b300000a@foolio1> (raw)

Hi,

In ppp_destroy_interface(), there is a chance that kfree(ppp) is called
twice, causing a kernel oops when ppp is opened again.  I was able to cause
this by running PPPOE, and killing -9 pppd and pppoe-daemon with one kill
command.  By doing this, the closing of ppp->dev causes a
ppp_disconnect_channel(), which calls kfree(ppp) assuming the ppp unit is
dead.  But destroy_interface() hasn't finished, and it tries to kfree(ppp)
also.  I simply moved the closing of the device to after the channels == 0
check.  Anyways, follows is the patch.  Please cc comments to
eli@routefree.com.

thanks,
Eli Chen


--- ppp_generic.c 2001/02/21 00:53:01 1.1.1.2
+++ ppp_generic.c 2001/07/03 20:37:22
@@ -2268,13 +2268,6 @@
  ppp->dev = 0;
  ppp_unlock(ppp);

- if (dev) {
-  rtnl_lock();
-  dev_close(dev);
-  unregister_netdevice(dev);
-  rtnl_unlock();
- }
-
  /*
   * We can't acquire any new channels (since we have the
   * all_ppp_lock) so if n_channels is 0, we can free the
@@ -2283,6 +2276,13 @@
   */
  if (ppp->n_channels == 0)
   kfree(ppp);
+
+ if (dev) {
+  rtnl_lock();
+  dev_close(dev);
+  unregister_netdevice(dev);
+  rtnl_unlock();
+ }

  spin_unlock(&all_ppp_lock);
 }



                 reply	other threads:[~2001-07-03 20:50 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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='034101c10401$feec9340$b300000a@foolio1' \
    --to=eli@routefree.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulus@linuxcare.com.au \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.