linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Li,Rongqing" <lirongqing@baidu.com>
To: "Kohli, Gaurav" <gkohli@codeaurora.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"jslaby@suse.com" <jslaby@suse.com>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"alan@linux.intel.com" <alan@linux.intel.com>
Subject: 答复: [PATCH][v2] tty: fix race between flush_to_ldisc and tty_open
Date: Mon, 14 Jan 2019 02:51:34 +0000	[thread overview]
Message-ID: <3a26e298dc604350b6ecf4e3381009a8@baidu.com> (raw)
In-Reply-To: <fc359e35-6b07-832b-6770-46f00d1a84c6@codeaurora.org>

> -----邮件原件-----
> 发件人: Kohli, Gaurav [mailto:gkohli@codeaurora.org]
> 发送时间: 2019年1月11日 21:57
> 收件人: Li,Rongqing <lirongqing@baidu.com>; linux-kernel@vger.kernel.org;
> jslaby@suse.com; gregkh@linuxfoundation.org; alan@linux.intel.com
> 主题: Re: [PATCH][v2] tty: fix race between flush_to_ldisc and tty_open
> 
> Hi,
> 
> it don't seems to be good idea to put lock on one function and unlock in some
> other function. If in future some one has to call tty_init_dev, how he can track
> the unlocking as well of ldisc lock.
> 
> Regards
> Gaurav
> 

This similar condition has existed for a long time, tty_unlock(tty) must be called in
some other functions who call tty_init_dev, since tty_init_dev hold tty_lock, and does
not release it

so I think it is user responsibility to fully understand tty_init_dev; and I can add some 
comments for tty_init_dev if this patch can be acceptable;


or a workaround like below:
diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
index a42a028a9d4e..2f5ad256b6ad 100644
--- a/drivers/tty/tty_buffer.c
+++ b/drivers/tty/tty_buffer.c
@@ -425,7 +425,7 @@ static void flush_to_ldisc(struct work_struct *work)
        struct tty_ldisc *disc;
 
        tty = port->itty;
-       if (tty == NULL)
+       if (tty == NULL || tty->driver_data == NULL)
                return;
 
        disc = tty_ldisc_ref(tty);

thanks

-RongQing




      reply	other threads:[~2019-01-14  3:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-24  2:43 [PATCH][v2] tty: fix race between flush_to_ldisc and tty_open Li RongQing
2019-01-11 13:57 ` Kohli, Gaurav
2019-01-14  2:51   ` Li,Rongqing [this message]

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=3a26e298dc604350b6ecf4e3381009a8@baidu.com \
    --to=lirongqing@baidu.com \
    --cc=alan@linux.intel.com \
    --cc=gkohli@codeaurora.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.com \
    --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 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).