From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by befuddled.reisers.ca (Postfix, from userid 65534) id 44BD31EFDF6; Mon, 10 Jul 2017 12:13:39 -0400 (EDT) Received: from mail-wr0-f194.google.com (mail-wr0-f194.google.com [209.85.128.194]) by befuddled.reisers.ca (Postfix) with ESMTPS id 549EC1EFDE5 for ; Mon, 10 Jul 2017 12:13:36 -0400 (EDT) Received: by mail-wr0-f194.google.com with SMTP id 77so25907226wrb.3 for ; Mon, 10 Jul 2017 09:13:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=kryFx8t5/7OTsEmYGB+v+UmEy9YiJpCpVqHWSS8uev4=; b=juqqPYtJnDl1hhoQxb41qIEBRNjwhIXHtrlN3fjk9FBM7PnEzL0L1iAgIIFbVZUZCE vob/1k/eqm3dOhVV7OkkqJmGR8eA0PnfoYWEsX7Rfjq1XCLBy6cEGKUsNtwhVL4n6/mX AIWCnN/PTJzh+i+kjLM5bL3p4uJqe0Ddpu39Dcf1dpQu0pOTZF20aFICyZQ7GTdZYSOQ 45/QIsc31EwyyK1cqd57vXFHOlRLCa600Uq9/0lAn9Kv37ZCwm888C7lLJfDbVLcfDbI daytdIJzro3mmiiS6L5VGnS4M61Tnx9qkiMZpJXt2PIi74W4Rf9jkeIyxT1QtE9/5hSi bNLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=kryFx8t5/7OTsEmYGB+v+UmEy9YiJpCpVqHWSS8uev4=; b=JVWRUmRDobU6MGQbGf5oEKkTKZgATE1FVatQd4Hyz7nj8xSgSJawmAjRj4AjquBdn4 XLni3ilAGbivHcNDS9Iu1ot15LevZDtFJ4Oz/ZcQLI4EJZvhq8z5p3J+fKDh6Zd5pznu 2BFhi2BRhB0FsyA0mLnQsfBXyiYvZXst/sSQeK6Uc1TW8G192D0XdMaVFBwhMi3aUxWo 3JGzTFokeoW0NA+VOQN6wTftpsHj2sGbU0vOpnRblEfcKgtjll0KdJdTcc7TP8kEgZTm bZN7O9Li7iT6XpCaF0sJcQFWUKJfsml6gLdgjncwLcVHBBDVb4m3jxzvOP76X92rATfS Hf3g== X-Gm-Message-State: AIVw111friRNE53pltRNsR3q3YNXJZ5IA+ikk3SIpUMg5w4Z6JyqvZsB hkTfcpZpEKSFRw== X-Received: by 10.223.152.240 with SMTP id w103mr8195422wrb.64.1499703155202; Mon, 10 Jul 2017 09:12:35 -0700 (PDT) Received: from sanghar ([2a00:23c4:7320:5900:224:d6ff:fe76:7136]) by smtp.gmail.com with ESMTPSA id n205sm5600919wmf.21.2017.07.10.09.12.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2017 09:12:34 -0700 (PDT) Date: Mon, 10 Jul 2017 17:12:31 +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: <20170710161231.GA417@sanghar> References: <20170708083803.GA23080@kroah.com> <20170709114153.157783481@gmail.com> <20170709114426.618570903@gmail.com> <20170710083105.GA719@sanghar> 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) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 X-BeenThere: speakup@linux-speakup.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Speakup is a screen review system for Linux." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Jul 2017 16:13:39 -0000 On Mon, Jul 10, 2017 at 06:21:37PM +0300, Andy Shevchenko wrote: > On Mon, Jul 10, 2017 at 11:31 AM, Okash Khawaja wrote: > > 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. > > Yeah, and my point is to use goto with the symmetric giveups of lock > and reference. Ah okay I see your point. Sure, I don't mind either way. However, this code closely follows tty_open_by_driver, so I have tried to keep the same pattern for sake of consistency :) Thanks, Okash