public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tty:tty_ldisc: add tty_ldisc_lock|unlock to prevent concurrent update to ldisc in tty_ldisc_deinit
@ 2017-04-09 16:59 Wang YanQing
  2017-04-10  0:33 ` Michael Neuling
  0 siblings, 1 reply; 2+ messages in thread
From: Wang YanQing @ 2017-04-09 16:59 UTC (permalink / raw)
  To: gregkh
  Cc: jslaby, linux-kernel, mikey, viro, johan, peter, alex.popov, robh,
	mpatocka, dvyukov, benh

This patch could fix the issue that free_tty_struct in tty_io
calling tty_ldisc_deinit without holding tty->ldisc_sem.

Signed-off-by: Wang YanQing <udknight@gmail.com>
---
 drivers/tty/tty_ldisc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
index b1f7fa5..674421b 100644
--- a/drivers/tty/tty_ldisc.c
+++ b/drivers/tty/tty_ldisc.c
@@ -771,7 +771,9 @@ void tty_ldisc_init(struct tty_struct *tty)
  */
 void tty_ldisc_deinit(struct tty_struct *tty)
 {
+	tty_ldisc_lock(tty, MAX_SCHEDULE_TIMEOUT);
 	if (tty->ldisc)
 		tty_ldisc_put(tty->ldisc);
 	tty->ldisc = NULL;
+	tty_ldisc_unlock(tty);
 }
-- 
1.8.5.6.2.g3d8a54e.dirty

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

end of thread, other threads:[~2017-04-10  0:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-09 16:59 [PATCH] tty:tty_ldisc: add tty_ldisc_lock|unlock to prevent concurrent update to ldisc in tty_ldisc_deinit Wang YanQing
2017-04-10  0:33 ` Michael Neuling

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox