All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gianluca Anzolin <gianluca@sottospazio.it>
To: jslaby@suse.cz
Cc: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Fix refcount leak in tty_port.c
Date: Fri, 12 Jul 2013 11:47:33 +0200	[thread overview]
Message-ID: <20130712094733.GA28317@debian.seek.priv> (raw)
In-Reply-To: <20130709083535.GA30227>

Hello,

I'm sorry to bother you again, I'm just pinging to see if you received the
patch or if it got lost in the noise. It fixes a regression introduced in git
commit aa27a094e2c2e

I have another patch for rfcomm tty waiting for this fix to get applied.

Thank you,

Gianluca

On Tue, Jul 09, 2013 at 10:35:35AM +0200, Gianluca Anzolin wrote:
> Hello,
> 
> In linux 3.10 in the file drivers/tty/tty_port.c the function
> tty_port_tty_hangup may leak a tty reference:
> 
>         struct tty_struct *tty = tty_port_tty_get(port);
> 
>         if (tty && (!check_clocal || !C_CLOCAL(tty))) {
>                 tty_hangup(tty);
>                 tty_kref_put(tty);
>         }
> 
> If tty != NULL and the second condition is false we never call tty_kref_put and
> the reference is leaked.
> 
> Fix by nesting two if statements.
> 
> Signed-off-by: Gianluca Anzolin <gianluca@sottospazio.it>

> diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
> index 121aeb9..2198f7d 100644
> --- a/drivers/tty/tty_port.c
> +++ b/drivers/tty/tty_port.c
> @@ -256,8 +256,9 @@ void tty_port_tty_hangup(struct tty_port *port, bool check_clocal)
>  {
>  	struct tty_struct *tty = tty_port_tty_get(port);
>  
> -	if (tty && (!check_clocal || !C_CLOCAL(tty))) {
> -		tty_hangup(tty);
> +	if (tty) {
> +		if (!check_clocal || !C_CLOCAL(tty))
> +			tty_hangup(tty);
>  		tty_kref_put(tty);
>  	}
>  }


       reply	other threads:[~2013-07-12  9:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20130709083535.GA30227>
2013-07-12  9:47 ` Gianluca Anzolin [this message]
2013-07-12 15:12   ` [PATCH] Fix refcount leak in tty_port.c Greg KH
2013-07-09  8:35 Gianluca Anzolin
2013-07-12 10:30 ` Gustavo Padovan
2013-07-12 14:04   ` Peter Hurley
2013-07-24 14:11     ` Peter Hurley
2013-07-24 22:15       ` Greg KH

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=20130712094733.GA28317@debian.seek.priv \
    --to=gianluca@sottospazio.it \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    /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.