All of lore.kernel.org
 help / color / mirror / Atom feed
From: xinhui <mnipxh@gmail.com>
To: Peter Hurley <peter@hurleysoftware.com>,
	"xinhui.pan" <xinhuix.pan@intel.com>
Cc: Greg KH <gregkh@linuxfoundation.org>,
	jslaby@suse.cz, linux-kernel@vger.kernel.org,
	yanmin_zhang@linux.intel.com
Subject: Re: [PATCH] tty/tty_io.c: make a check before reuse cdev
Date: Fri, 25 Jul 2014 23:24:46 +0800	[thread overview]
Message-ID: <53D276BE.20901@gmail.com> (raw)
In-Reply-To: <53CFDD05.4010104@hurleysoftware.com>

hi, Peter

On 2014年07月24日 00:04, Peter Hurley wrote:
> Hi Xinhui,
> 
> On 07/23/2014 05:21 AM, xinhui.pan wrote:
>> 于 2014年07月23日 00:40, Peter Hurley 写道:
>>> On 07/22/2014 07:52 AM, xinhui.pan wrote:
>>>> 于 2014年07月21日 23:38, Greg KH 写道:
>>>>> On Mon, Jul 21, 2014 at 08:47:16PM +0800, pp wrote:
> 
>>>>>> tty driver register its device and (D)init the cdevs again.
>>>>>
>>>>> What driver does this with an "old" device, it should have created a new
>>>>> one, otherwise, as you have pointed out, it's a bug.
>>>>>
>>>>
>>>> I can't agree more with you. we should not use "old" device.
>>>
>>> This is a gsm driver problem. The GSM driver is reusing device indexes
>>> for still-open ttys.
>>>
>>> The GSM driver uses a global table, gsm_mux[], to allocate device indexes
>>> but prematurely clears the table entry in gsm_mux_cleanup(). If instead,
>>> clearing the gsm_mux table entry were deferred to gsm_mux_free(), then
>>> device indexes would not be getting reused until after the last tty
>>> associated with the last gsm attach was closed.
>>>
>>
>> Very nice solution. We will check if this can cause any risk, both to kernel and user space.
>> Using a new tty base to register with new cdevs may give us more chance to wait PROCESS quit/close.
>> when total 256 tty used up, what we should do is still in discuss.
> 
> I saw your patch for the use of gsm->num before gsm_activate_mux() has
> allocated the table entry; thanks for fixing that.
> 
> As for what to do if all the gsm_mux table entries are used: if the error
> is infrequent, I suggest simply returning an error which is what the
> driver does currently. Otherwise, a more dynamic allocation scheme may be required.
> 
> I did notice while reviewing the error handling that gsmld_open() will
> leak the entire composite ldisc data allocated by gsm_alloc_mux() if
> gsmld_attach_gsm() fails.
> 

As for memory leak, I suggest move the codes that changing the index of gsm_mux[] into gsm_alloc_mux/gsm_free_mux.
That makes things much easier to understand. And everything should be OK, including base = gsm->num << 6 :)

I think gsm_mux[] holds the gsms whcih we are able to use, not we are using. *able to use* includes *using*.

If you have any different opinions, could you point out my mistake?

thanks,

xinhui

> Regards,
> Peter Hurley
> 

  parent reply	other threads:[~2014-07-25 15:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-21 12:47 [PATCH] tty/tty_io.c: make a check before reuse cdev pp
2014-07-21 15:38 ` Greg KH
2014-07-22 11:52   ` xinhui.pan
2014-07-22 16:40     ` Peter Hurley
2014-07-22 17:38       ` Greg KH
2014-07-23  9:21       ` xinhui.pan
2014-07-23 16:04         ` Peter Hurley
2014-07-24 10:23           ` xinhui.pan
2014-07-25 15:24           ` xinhui [this message]
2014-07-23 16:07         ` One Thousand Gnomes
2014-07-24 11:01           ` xinhui.pan
2014-07-24 11:03           ` xinhui.pan

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=53D276BE.20901@gmail.com \
    --to=mnipxh@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peter@hurleysoftware.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.