Re: [PATCH] tty: fix data race in n_tty_receive_buf_common

From: Kohli, Gaurav
Date: Fri Jan 05 2018 - 02:46:22 EST


Hi Alan,

Can you make that code available otherwise it's impossible to see what the problem might be.


Âhttps://source.codeaurora.org/quic/la/kernel/msm-4.9/tree/drivers/tty/serial?h=msm-4.9
ÂAs discussed , there not seems a problem as we are getting print request even when port seems to closed.


tty_ldisc_lock(tty, 5 * HZ);
Âtty_ldisc_setup(tty);
Âtty_ldisc_unlock(tty)

But in above lock, there is a chance when flush_to_ldisc will occur first and acquired a lock in
tty_ldisc_ref itself.
So this may fail, I am not much sure here, Please correct me, If i am missing something here.
So can not we simply return from flush_to_ldisc ,when we know disc_data is not valid like
we are doing for tty and ldisc already?

if (tty->disc_data == NULL) {
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ tty_ldisc_deref(disc);
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ return;
ÂÂÂÂÂÂÂ }






Regards
Gaurav
-- Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.