From: Greg KH <gregkh@linuxfoundation.org>
To: Pan Xinhui <xinhuix.pan@intel.com>
Cc: jslaby@suse.cz, linux-kernel@vger.kernel.org,
yanmin_zhang@linux.intel.com, mnipxh@gmai.com
Subject: Re: [PATCH v2] tty/n_gsm.c: fix a memory leak when gsmtty is removed
Date: Thu, 26 Mar 2015 22:36:00 +0100 [thread overview]
Message-ID: <20150326213600.GA29139@kroah.com> (raw)
In-Reply-To: <55125E3D.2070109@intel.com>
On Wed, Mar 25, 2015 at 03:05:33PM +0800, Pan Xinhui wrote:
> when gsmtty_remove put dlci, it will cause memory leak if
> dlci->port's refcount is zero.
> So we do the cleanup work in .cleanup callback instead.
>
> dlci will be last put in two call chains.
> 1) gsmld_close -> gsm_cleanup_mux -> gsm_dlci_release -> dlci_put
> 2) gsmld_remove -> dlci_put
> so there is a race. the memory leak depends on the race.
>
> In call chain 2. we hit the memory leak. bellow comment tells.
>
> release_tty -> tty_driver_remove_tty -> gsmtty_remove -> dlci_put -> tty_port_destructor (WARN_ON(port->itty) and return directly)
> |
> --> tty->port->itty = NULL;
> |
> tty_kref_put ---> release_one_tty -> gsmtty_cleanup (now we do the cleanup work here.)
That doesn't line up at all :(
> So our patch fix it by doing the cleanup work after tty core did.
>
> Signed-off-by: xinhui.pan <xinhuix.pan@intel.com>
I need a real name here, "xinhui.pan" is not your real name, according
to your "From:" line, right?
Please fix up and resend.
And also include what changed from the previous version, this is much
different.
thanks,
greg k-h
next prev parent reply other threads:[~2015-03-26 21:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-24 7:26 [PATCH] tty/n_gsm.c: fix a memory leak when gsmtty is removed Pan Xinhui
2015-03-25 7:05 ` [PATCH v2] " Pan Xinhui
2015-03-26 21:36 ` Greg KH [this message]
2015-03-28 2:42 ` [PATCH v2 RESEND] " Pan Xinhui
2015-03-27 8:51 ` Jiri Slaby
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=20150326213600.GA29139@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=jslaby@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=mnipxh@gmai.com \
--cc=xinhuix.pan@intel.com \
--cc=yanmin_zhang@linux.intel.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 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.