linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tty:n_gsm.c: destroy port by tty_port_destroy()
@ 2019-09-24  9:25 Xiaoming Ni
  2019-10-31 10:11 ` Jiri Slaby
  0 siblings, 1 reply; 4+ messages in thread
From: Xiaoming Ni @ 2019-09-24  9:25 UTC (permalink / raw)
  To: gregkh, jslaby; +Cc: linux-kernel, nixiaoming

According to the comment of tty_port_destroy():
    When a port was initialized using tty_port_init, one has to destroy
    the port by tty_port_destroy();

tty_port_init() is called in gsm_dlci_alloc()
so tty_port_destroy() needs to be called in gsm_dlci_free()

Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com>
---
 drivers/tty/n_gsm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index 36a3eb4..3f5bcc9 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -1681,6 +1681,7 @@ static void gsm_dlci_free(struct tty_port *port)
 
 	del_timer_sync(&dlci->t1);
 	dlci->gsm->dlci[dlci->addr] = NULL;
+	tty_port_destroy(&dlci->port);
 	kfifo_free(dlci->fifo);
 	while ((dlci->skb = skb_dequeue(&dlci->skb_list)))
 		dev_kfree_skb(dlci->skb);
-- 
1.8.5.6


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] tty:n_gsm.c: destroy port by tty_port_destroy()
  2019-09-24  9:25 [PATCH] tty:n_gsm.c: destroy port by tty_port_destroy() Xiaoming Ni
@ 2019-10-31 10:11 ` Jiri Slaby
  2019-10-31 12:38   ` Xiaoming Ni
  2019-11-04 16:49   ` Greg KH
  0 siblings, 2 replies; 4+ messages in thread
From: Jiri Slaby @ 2019-10-31 10:11 UTC (permalink / raw)
  To: Xiaoming Ni, gregkh; +Cc: linux-kernel

On 24. 09. 19, 11:25, Xiaoming Ni wrote:
> According to the comment of tty_port_destroy():
>     When a port was initialized using tty_port_init, one has to destroy
>     the port by tty_port_destroy();

It continues with a part saying:
   Either indirectly by using tty_port refcounting
   (tty_port_put) or directly if refcounting is not used.

> tty_port_init() is called in gsm_dlci_alloc()
> so tty_port_destroy() needs to be called in gsm_dlci_free()
> 
> Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com>
> ---
>  drivers/tty/n_gsm.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
> index 36a3eb4..3f5bcc9 100644
> --- a/drivers/tty/n_gsm.c
> +++ b/drivers/tty/n_gsm.c
> @@ -1681,6 +1681,7 @@ static void gsm_dlci_free(struct tty_port *port)
>  
>  	del_timer_sync(&dlci->t1);
>  	dlci->gsm->dlci[dlci->addr] = NULL;
> +	tty_port_destroy(&dlci->port);

This is wrong. gsm_dlci_free is tty_port_operations->destruct, i.e.
n_gsm uses tty_port refcounting and tty_port_destroy was called on this
port in tty_port_destructor already.

Greg, please revert.

thanks,
-- 
js
suse labs

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] tty:n_gsm.c: destroy port by tty_port_destroy()
  2019-10-31 10:11 ` Jiri Slaby
@ 2019-10-31 12:38   ` Xiaoming Ni
  2019-11-04 16:49   ` Greg KH
  1 sibling, 0 replies; 4+ messages in thread
From: Xiaoming Ni @ 2019-10-31 12:38 UTC (permalink / raw)
  To: Jiri Slaby, gregkh; +Cc: linux-kernel

On 2019/10/31 18:11, Jiri Slaby wrote:
> On 24. 09. 19, 11:25, Xiaoming Ni wrote:
>> According to the comment of tty_port_destroy():
>>      When a port was initialized using tty_port_init, one has to destroy
>>      the port by tty_port_destroy();
> 
> It continues with a part saying:
>     Either indirectly by using tty_port refcounting
>     (tty_port_put) or directly if refcounting is not used.
> 
>> tty_port_init() is called in gsm_dlci_alloc()
>> so tty_port_destroy() needs to be called in gsm_dlci_free()
>>
>> Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com>
>> ---
>>   drivers/tty/n_gsm.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
>> index 36a3eb4..3f5bcc9 100644
>> --- a/drivers/tty/n_gsm.c
>> +++ b/drivers/tty/n_gsm.c
>> @@ -1681,6 +1681,7 @@ static void gsm_dlci_free(struct tty_port *port)
>>   
>>   	del_timer_sync(&dlci->t1);
>>   	dlci->gsm->dlci[dlci->addr] = NULL;
>> +	tty_port_destroy(&dlci->port);
> 
> This is wrong. gsm_dlci_free is tty_port_operations->destruct, i.e.
> n_gsm uses tty_port refcounting and tty_port_destroy was called on this
> port in tty_port_destructor already.
> 
> Greg, please revert.
> 
> thanks,
> 

Function call flow
tty_port_put
     ===>  tty_port_destructor
          ===> tty_port_destroy
               Port->ops->destruct(port);
                ===> .destruct = gsm_dlci_free

Thank you for your correction, I am wrong.

thanks


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] tty:n_gsm.c: destroy port by tty_port_destroy()
  2019-10-31 10:11 ` Jiri Slaby
  2019-10-31 12:38   ` Xiaoming Ni
@ 2019-11-04 16:49   ` Greg KH
  1 sibling, 0 replies; 4+ messages in thread
From: Greg KH @ 2019-11-04 16:49 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: Xiaoming Ni, linux-kernel

On Thu, Oct 31, 2019 at 11:11:24AM +0100, Jiri Slaby wrote:
> On 24. 09. 19, 11:25, Xiaoming Ni wrote:
> > According to the comment of tty_port_destroy():
> >     When a port was initialized using tty_port_init, one has to destroy
> >     the port by tty_port_destroy();
> 
> It continues with a part saying:
>    Either indirectly by using tty_port refcounting
>    (tty_port_put) or directly if refcounting is not used.
> 
> > tty_port_init() is called in gsm_dlci_alloc()
> > so tty_port_destroy() needs to be called in gsm_dlci_free()
> > 
> > Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com>
> > ---
> >  drivers/tty/n_gsm.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
> > index 36a3eb4..3f5bcc9 100644
> > --- a/drivers/tty/n_gsm.c
> > +++ b/drivers/tty/n_gsm.c
> > @@ -1681,6 +1681,7 @@ static void gsm_dlci_free(struct tty_port *port)
> >  
> >  	del_timer_sync(&dlci->t1);
> >  	dlci->gsm->dlci[dlci->addr] = NULL;
> > +	tty_port_destroy(&dlci->port);
> 
> This is wrong. gsm_dlci_free is tty_port_operations->destruct, i.e.
> n_gsm uses tty_port refcounting and tty_port_destroy was called on this
> port in tty_port_destructor already.
> 
> Greg, please revert.

Now reverted.

sorry about that.

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-11-04 16:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-24  9:25 [PATCH] tty:n_gsm.c: destroy port by tty_port_destroy() Xiaoming Ni
2019-10-31 10:11 ` Jiri Slaby
2019-10-31 12:38   ` Xiaoming Ni
2019-11-04 16:49   ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).