[PATCH] tty:tty_ldisc: add tty_ldisc_lock|unlock to prevent concurrent update to ldisc in tty_ldisc_deinit
From: Wang YanQing
Date: Sun Apr 09 2017 - 13:05:49 EST
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@xxxxxxxxx>
---
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