Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2621016pxb; Sun, 17 Oct 2021 20:45:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3RljFXuL2jopIwQ4lJsr9Dt50el/TsChQmy9LErRsWE3fzMronPgMoq0fXS2DPt9zObwp X-Received: by 2002:a63:b51a:: with SMTP id y26mr11495454pge.143.1634528703482; Sun, 17 Oct 2021 20:45:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634528703; cv=none; d=google.com; s=arc-20160816; b=X2NAmHbJkKoz9qviA6ZF2kHkp8a2JxIKkj79MaCXtZhPbmCTK8DxfuyMbQxGJc0YPC fj5g8zgbVN9Vdsv7VBM85ZOu2zYYNOkRa9Y7vFG/Kbj7+Q3hhrfD7R8fZud8yA5HE10X YkTKMdS81qEnp/hFsb32nwH3PJNWesup5hTlDGJk2CezLfYjKM5UsSEgekD/+DOcGBIb KS2+S7umydUENEtsMrdd1m68KMUR5ssCN2Lad6JCXfHRAne7q3ssJVr5OA0n8S0Lz4rQ fvcjAnbb2xWRrFz0+wSutr8DtDMJI34bkiqZ+E+TFhk3fZW0b1oB4f+u2KvnNd4Mc6+q 5kxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=gPcB1VfNsMVF6SNIXYghgogd42tDGhrBLF5CFQgESz4=; b=kyr4qcOqhlCBjzl2q4mf+cSc68ex9rdwpgpeaQbjDqFeuKLTaiP/nId6tLXlu6VwVW DBc5atKVlmXSCGE6KHlPHI4NxE5/k/3lH+mW3Z5tGo4ZDYuZQvqoUhiPJC9njY7SwWKQ /oUAAZKgVcvvXuoTLgjTV8Z61q+zOLdvdM2ywY++bo7Q5eZJYR35GJqnsgyXE/yswKOz Hvi7S1Nlel1OZV5/FhfXkwjMlMFOkdnBU+uwfPxLR3RAHTaUNoE0mDGv5ca0AJZoN+G7 Sf9SVo9r+3bi81zUSr7mSq4/iKWdIWgupOnyg85WZWP3BLNwUcQiKbXPiI0w22KQJNET +y8A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b6si12981477pgr.51.2021.10.17.20.44.48; Sun, 17 Oct 2021 20:45:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242463AbhJQOE4 (ORCPT + 98 others); Sun, 17 Oct 2021 10:04:56 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:36301 "EHLO relay7-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232132AbhJQOEz (ORCPT ); Sun, 17 Oct 2021 10:04:55 -0400 Received: (Authenticated sender: alexandre.belloni@bootlin.com) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 5112E20005; Sun, 17 Oct 2021 14:02:42 +0000 (UTC) Date: Sun, 17 Oct 2021 16:02:42 +0200 From: Alexandre Belloni To: Greg KH Cc: William Breathitt Gray , jic23@kernel.org, linux-stm32@st-md-mailman.stormreply.com, kernel@pengutronix.de, a.fatoum@pengutronix.de, kamel.bouhara@bootlin.com, gwendal@chromium.org, david@lechnology.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, syednwaris@gmail.com, patrick.havelange@essensium.com, fabrice.gasnier@st.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, o.rempel@pengutronix.de, jarkko.nikula@linux.intel.com, Dan Carpenter Subject: Re: [PATCH v17 2/9] counter: Add character device interface Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 17/10/2021 15:50:11+0200, Greg KH wrote: > Note, review of this now that it has been submitted in a pull request to > me, sorry I missed this previously... > > On Wed, Sep 29, 2021 at 12:15:59PM +0900, William Breathitt Gray wrote: > > +static int counter_chrdev_open(struct inode *inode, struct file *filp) > > +{ > > + struct counter_device *const counter = container_of(inode->i_cdev, > > + typeof(*counter), > > + chrdev); > > + > > + /* Ensure chrdev is not opened more than 1 at a time */ > > + if (!atomic_add_unless(&counter->chrdev_lock, 1, 1)) > > + return -EBUSY; > > I understand the feeling that you wish to stop userspace from doing > this, but really, it does not work. Eventhough you are doing this > correctly (you should see all the other attempts at doing this), you are > not preventing userspace from having multiple processes access this > device node at the same time, so please, don't even attempt to stop this > from happening. > > So you can drop the atomic "lock" you have here, it's not needed at all. > Could you elaborate a bit here because we've had a similar thing in the RTC subsystem: https://elixir.bootlin.com/linux/latest/source/drivers/rtc/dev.c#L28 And it would mean I can remove rtc->flags completely. -- Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com