* [PATCH] Fix refcount leak in tty_port.c
@ 2013-07-09 8:35 Gianluca Anzolin
2013-07-12 10:30 ` Gustavo Padovan
0 siblings, 1 reply; 7+ messages in thread
From: Gianluca Anzolin @ 2013-07-09 8:35 UTC (permalink / raw)
To: jslaby; +Cc: gregkh, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 509 bytes --]
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>
[-- Attachment #2: tty_port.patch --]
[-- Type: text/x-diff, Size: 465 bytes --]
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);
}
}
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] Fix refcount leak in tty_port.c
2013-07-09 8:35 [PATCH] Fix refcount leak in tty_port.c Gianluca Anzolin
@ 2013-07-12 10:30 ` Gustavo Padovan
2013-07-12 14:04 ` Peter Hurley
0 siblings, 1 reply; 7+ messages in thread
From: Gustavo Padovan @ 2013-07-12 10:30 UTC (permalink / raw)
To: Gianluca Anzolin; +Cc: jslaby, gregkh, linux-kernel
Hi Gianluca,
* Gianluca Anzolin <gianluca@sottospazio.it> [2013-07-09 10:35:35 +0200]:
> 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>
As mentioned by Gianluca this is a regression of aa27a094 and we depend on
this patch to go ahead with some fixes in the bluetooth subsystem.
Gianluca, it might help if you send a proper git inline formated patch,
mentioning the issue and which regression you are fixing. It makes
maintainer's life easier. Also add my Ack to the patch:
Acked-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Gustavo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Fix refcount leak in tty_port.c
2013-07-12 10:30 ` Gustavo Padovan
@ 2013-07-12 14:04 ` Peter Hurley
2013-07-24 14:11 ` Peter Hurley
0 siblings, 1 reply; 7+ messages in thread
From: Peter Hurley @ 2013-07-12 14:04 UTC (permalink / raw)
To: Gustavo Padovan, Gianluca Anzolin, linux-kernel; +Cc: jslaby, gregkh
On 07/12/2013 06:30 AM, Gustavo Padovan wrote:
> Hi Gianluca,
>
> * Gianluca Anzolin <gianluca@sottospazio.it> [2013-07-09 10:35:35 +0200]:
>
>> 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.
Good catch.
>> Fix by nesting two if statements.
>>
>> Signed-off-by: Gianluca Anzolin <gianluca@sottospazio.it>
>
> As mentioned by Gianluca this is a regression of aa27a094 and we depend on
> this patch to go ahead with some fixes in the bluetooth subsystem.
Gustavo,
There's no direct dependency; ie., there aren't merge issues here.
We should progress with the fixes to rfcomm independent of this patch.
> Gianluca, it might help if you send a proper git inline formated patch,
> mentioning the issue and which regression you are fixing. It makes
> maintainer's life easier.
As Gustavo points out, please inline the patch otherwise commenters
have to do it for you.
> Also add my Ack to the patch:
>
>
> Acked-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
>
> Gustavo
Copy of the Gianluca's patch with my comments
--- %< ---
Please put a proper commit message here, including that this is
a regression and the commit id that caused the regression so this patch
can eventually make its way to stable.
> 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);
> }
> }
tty_kref_put() already checks for NULL tty. I would prefer:
{
struct tty_struct *tty = tty_port_tty_get(port);
if (tty && (!check_clocal || !C_CLOCAL(tty)))
tty_hangup(tty);
tty_kref_put(tty);
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Fix refcount leak in tty_port.c
2013-07-12 14:04 ` Peter Hurley
@ 2013-07-24 14:11 ` Peter Hurley
2013-07-24 22:15 ` Greg KH
0 siblings, 1 reply; 7+ messages in thread
From: Peter Hurley @ 2013-07-24 14:11 UTC (permalink / raw)
To: Gianluca Anzolin, gregkh; +Cc: Gustavo Padovan, linux-kernel, jslaby
On 07/12/2013 10:04 AM, Peter Hurley wrote:
> On 07/12/2013 06:30 AM, Gustavo Padovan wrote:
>> Hi Gianluca,
>>
>> * Gianluca Anzolin <gianluca@sottospazio.it> [2013-07-09 10:35:35 +0200]:
>>
>>> 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.
>
> Good catch.
>
>>> Fix by nesting two if statements.
>>>
>>> Signed-off-by: Gianluca Anzolin <gianluca@sottospazio.it>
>>
>> As mentioned by Gianluca this is a regression of aa27a094 and we depend on
>> this patch to go ahead with some fixes in the bluetooth subsystem.
>
> Gustavo,
>
> There's no direct dependency; ie., there aren't merge issues here.
> We should progress with the fixes to rfcomm independent of this patch.
>
>> Gianluca, it might help if you send a proper git inline formated patch,
>> mentioning the issue and which regression you are fixing. It makes
>> maintainer's life easier.
>
> As Gustavo points out, please inline the patch otherwise commenters
> have to do it for you.
Gianluca,
I think Greg may be expecting you to address the comments from myself
and Gustavo before accepting this patch.
Greg, is that the case?
Regards,
Peter Hurley
>> Also add my Ack to the patch:
> >
>>
>> Acked-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
>>
>> Gustavo
>
> Copy of the Gianluca's patch with my comments
>
> --- %< ---
>
> Please put a proper commit message here, including that this is
> a regression and the commit id that caused the regression so this patch
> can eventually make its way to stable.
>
>
> > 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);
> > }
> > }
>
>
> tty_kref_put() already checks for NULL tty. I would prefer:
>
> {
> struct tty_struct *tty = tty_port_tty_get(port);
>
> if (tty && (!check_clocal || !C_CLOCAL(tty)))
> tty_hangup(tty);
> tty_kref_put(tty);
> }
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Fix refcount leak in tty_port.c
2013-07-24 14:11 ` Peter Hurley
@ 2013-07-24 22:15 ` Greg KH
0 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2013-07-24 22:15 UTC (permalink / raw)
To: Peter Hurley; +Cc: Gianluca Anzolin, Gustavo Padovan, linux-kernel, jslaby
On Wed, Jul 24, 2013 at 10:11:47AM -0400, Peter Hurley wrote:
> On 07/12/2013 10:04 AM, Peter Hurley wrote:
> >On 07/12/2013 06:30 AM, Gustavo Padovan wrote:
> >>Hi Gianluca,
> >>
> >>* Gianluca Anzolin <gianluca@sottospazio.it> [2013-07-09 10:35:35 +0200]:
> >>
> >>>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.
> >
> >Good catch.
> >
> >>>Fix by nesting two if statements.
> >>>
> >>>Signed-off-by: Gianluca Anzolin <gianluca@sottospazio.it>
> >>
> >>As mentioned by Gianluca this is a regression of aa27a094 and we depend on
> >>this patch to go ahead with some fixes in the bluetooth subsystem.
> >
> >Gustavo,
> >
> >There's no direct dependency; ie., there aren't merge issues here.
> >We should progress with the fixes to rfcomm independent of this patch.
> >
> >>Gianluca, it might help if you send a proper git inline formated patch,
> >>mentioning the issue and which regression you are fixing. It makes
> >>maintainer's life easier.
> >
> >As Gustavo points out, please inline the patch otherwise commenters
> >have to do it for you.
>
> Gianluca,
>
> I think Greg may be expecting you to address the comments from myself
> and Gustavo before accepting this patch.
>
> Greg, is that the case?
Yes, I thought a new version was coming, so I dropped this one. Can
someone please fix this up and resend?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Fix refcount leak in tty_port.c
2013-07-12 9:47 ` Gianluca Anzolin
@ 2013-07-12 15:12 ` Greg KH
0 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2013-07-12 15:12 UTC (permalink / raw)
To: Gianluca Anzolin; +Cc: jslaby, linux-kernel
On Fri, Jul 12, 2013 at 11:47:33AM +0200, Gianluca Anzolin wrote:
> 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.
I have it, just waiting for 3.11-rc1 to come out before dealing with any
new patches.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Fix refcount leak in tty_port.c
[not found] <20130709083535.GA30227>
@ 2013-07-12 9:47 ` Gianluca Anzolin
2013-07-12 15:12 ` Greg KH
0 siblings, 1 reply; 7+ messages in thread
From: Gianluca Anzolin @ 2013-07-12 9:47 UTC (permalink / raw)
To: jslaby; +Cc: gregkh, linux-kernel
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);
> }
> }
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-07-24 22:15 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-09 8:35 [PATCH] Fix refcount leak in tty_port.c 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
[not found] <20130709083535.GA30227>
2013-07-12 9:47 ` Gianluca Anzolin
2013-07-12 15:12 ` Greg KH
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.