Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753526AbdGJIbZ (ORCPT ); Mon, 10 Jul 2017 04:31:25 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:35115 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752317AbdGJIbY (ORCPT ); Mon, 10 Jul 2017 04:31:24 -0400 Date: Mon, 10 Jul 2017 09:31:05 +0100 From: Okash Khawaja To: Andy Shevchenko Cc: Greg Kroah-Hartman , Jiri Slaby , Samuel Thibault , Alan Cox , "linux-kernel@vger.kernel.org" , William Hubbs , Chris Brannon , Kirk Reiser , speakup@linux-speakup.org, devel@driverdev.osuosl.org Subject: Re: [patch 1/3] tty: resolve tty contention between kernel and user space Message-ID: <20170710083105.GA719@sanghar> References: <20170708083803.GA23080@kroah.com> <20170709114153.157783481@gmail.com> <20170709114426.618570903@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.8.3 (2017-05-23) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 829 Lines: 29 On Sun, Jul 09, 2017 at 06:04:17PM +0300, Andy Shevchenko wrote: > On Sun, Jul 9, 2017 at 2:41 PM, Okash Khawaja wrote: > > > +struct tty_struct *tty_kopen(dev_t device) > > +{ > > + struct tty_struct *tty; > > + struct tty_driver *driver = NULL; > > + int index = -1; > > + > > + mutex_lock(&tty_mutex); > > + driver = tty_lookup_driver(device, NULL, &index); > > + if (IS_ERR(driver)) { > > > + mutex_unlock(&tty_mutex); > > + return ERR_CAST(driver); > > Hmm... perhaps > > tty = ERR_CAST(driver); > goto out_unlock; > > See below for further details. > Sorry missed this one out. Since tty_lookup_driver has failed, we don't need to down the refcount on driver. So we can return here, without going to out_unlock. Thanks, Okash