From: Gaurav Kohli <gkohli@codeaurora.org>
To: jslaby@suse.com, gregkh@linuxfoundation.org, mikey@neuling.org
Cc: linux-kernel@vger.kernel.org, Gaurav Kohli <gkohli@codeaurora.org>
Subject: [PATCH] tty: fix data race in n_tty_receive_buf_common
Date: Wed, 3 Jan 2018 19:18:52 +0530 [thread overview]
Message-ID: <1514987332-14122-1-git-send-email-gkohli@codeaurora.org> (raw)
There can be a race, if receive_buf call comes before
tty initialization completes in n_tty_open and tty->disc_data
may be NULL.
CPU0 cpu1
---- ----
000|n_tty_receive_buf_common() n_tty_open()
-001|n_tty_receive_buf2() tty_ldisc_open.isra.3()
-002|tty_ldisc_receive_buf(inline) tty_ldisc_setup()
If tty->disc_data is NULL, then return from flush_to_ldisc
Signed-off-by: Gaurav Kohli <gkohli@codeaurora.org>
diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
index 25d7368..5d49183 100644
--- a/drivers/tty/tty_port.c
+++ b/drivers/tty/tty_port.c
@@ -35,6 +35,9 @@ static int tty_port_default_receive_buf(struct tty_port *port,
if (!disc)
return 0;
+ if (!tty->disc_data)
+ return 0;
+
ret = tty_ldisc_receive_buf(disc, p, (char *)f, count);
tty_ldisc_deref(disc);
--
1.9.1
next reply other threads:[~2018-01-03 13:49 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-03 13:48 Gaurav Kohli [this message]
2018-01-03 19:38 ` Alan Cox
2018-01-04 5:47 ` Kohli, Gaurav
2018-01-04 11:09 ` Alan Cox
2018-01-04 13:46 ` Kohli, Gaurav
2018-01-04 14:37 ` Alan Cox
2018-01-05 7:34 ` Kohli, Gaurav
2018-01-05 7:45 ` Kohli, Gaurav
2018-01-05 13:36 ` Alan Cox
2018-01-05 13:56 ` Kohli, Gaurav
2018-01-05 14:15 ` Alan Cox
2018-01-05 20:14 ` Kohli, Gaurav
2018-01-05 20:24 ` Kohli, Gaurav
2018-01-05 21:05 ` Alan Cox
2018-01-06 7:50 ` Kohli, Gaurav
2018-01-17 13:25 ` Kohli, Gaurav
2018-01-20 18:49 ` Alan Cox
2018-01-05 20:28 ` Kohli, Gaurav
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=1514987332-14122-1-git-send-email-gkohli@codeaurora.org \
--to=gkohli@codeaurora.org \
--cc=gregkh@linuxfoundation.org \
--cc=jslaby@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mikey@neuling.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
Powered by JetHome