From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84E35C433F5 for ; Sun, 17 Oct 2021 13:51:44 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4A2CC60FE3 for ; Sun, 17 Oct 2021 13:51:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4A2CC60FE3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Z0GlIXhAnXcSIcRXOH+IPhhDWXp/vRkFdlPYi4/ysRg=; b=DqBzkbcu1v3LCp wE+GvynkVuMzpkEIfddUbNa8QSHFE/QmeD+3rONnukeM9zXychV/dcjTiVZkp8Ve23OUasEH5slKf W80F9nUz5hdLi63/gLGHEgAmYhgn7IUu7GP5FVpbCNFigKqcvTChwk/eioh/QRFpxrVM5BCg1Ejwi e7cchwreBAkNtjcQryClnVUqwU9u0v06E03ZFdpIDTTq4eZKRx0dGk9kL3N/Vrzl5IHADRK/S4+Pr jKaWiRs3peGRzd6Nh25BKaACzc4qDOy6uDhYnakIzlvZaS8uu5SNeBT0h8gvaQkdOfh3cmM28q31B m8KBGGXlxqSdMUmjvK3w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mc6YN-00CgOw-DE; Sun, 17 Oct 2021 13:50:19 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mc6YJ-00CgNw-CV for linux-arm-kernel@lists.infradead.org; Sun, 17 Oct 2021 13:50:17 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id CB18C61039; Sun, 17 Oct 2021 13:50:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634478614; bh=tfA7oucleLVKuvXIcjTuZZfdbNUsWA+rU4EDlt0R3OY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=V6ULbkcWXClmBXpwMjJCozJ45kjb60ISvdM+ofe247OQQ3jjQDvK4WElPV1B4oplQ UkJqtG0kM3j2UJ45i7Oc3YsnN8cYYFG1oKMPtuR94C9nApvv+Oo5X7dtMyOl6INU5b cjE0lgeY4IA0AtuEOkUGAYu3rBDAjb8IasF367b8= Date: Sun, 17 Oct 2021 15:50:11 +0200 From: Greg KH To: William Breathitt Gray Cc: jic23@kernel.org, linux-stm32@st-md-mailman.stormreply.com, kernel@pengutronix.de, a.fatoum@pengutronix.de, kamel.bouhara@bootlin.com, gwendal@chromium.org, alexandre.belloni@bootlin.com, 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-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211017_065015_476516_4E69EB87 X-CRM114-Status: GOOD ( 12.00 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. thanks, greg k-h _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel