From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alan Cox Subject: Re: [PATCH V1] tty: fix data race between tty_init_dev and flush of buf Date: Sat, 20 Jan 2018 18:48:52 +0000 Message-ID: <20180120184852.456d92ad@alans-desktop> References: <1516195459-1080-1-git-send-email-gkohli@codeaurora.org> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Return-path: Received: from www.llwyncelyn.cymru ([82.70.14.225]:45548 "EHLO fuzix.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756533AbeATSts (ORCPT ); Sat, 20 Jan 2018 13:49:48 -0500 In-Reply-To: <1516195459-1080-1-git-send-email-gkohli@codeaurora.org> Sender: linux-arm-msm-owner@vger.kernel.org List-Id: linux-arm-msm@vger.kernel.org To: Gaurav Kohli Cc: jslaby@suse.com, gregkh@linuxfoundation.org, mikey@neuling.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, stable@kernel.org On Wed, 17 Jan 2018 18:54:19 +0530 Gaurav Kohli wrote: > 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() > > Using ldisc semaphore lock in tty_init_dev till disc_data > initializes completely. > > Signed-off-by: Gaurav Kohli Reviewed-by: Alan Cox Alan