Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2620833pxb; Sun, 17 Oct 2021 20:44:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfw3ErB2Ch4ZAvfIH6iXHD89Z6/dcuwV0qsaE1uzQNvaIHefE062o6jKZfP1PW+QrNZChn X-Received: by 2002:a17:90a:245:: with SMTP id t5mr28681482pje.133.1634528688726; Sun, 17 Oct 2021 20:44:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634528688; cv=none; d=google.com; s=arc-20160816; b=mBYubjKCjcoySR1xlmasxaKtKKhhGpODD+2tYaeC+h5huksC4RTIJnXNBILUREHgyA orsgQg35XUcYVuNjRBRIMf7oCAYve4Pxpj/n7ajUHez1youeGmaDkRc0jRqvyNDzGMi1 4YCtQ/n7FB8Uxel/KwvOPFFhfxRmLoKBLyEknfiuH00pF8IGXvATcqIXCxOI+anpollt Grk6SQ6UQ+mR5fTrqx4UqM2QzTYKAVGqDic0VfgVklYx+1QFqZV470qhVQe3RHH2roHr FC9NjpdnLAVFWf4SnUsFbf1fZXUDtrPjsrT4UR9YBiLAzQ5RGjpLhD9BvMYSvtYR6m0s oPzg== 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:dkim-signature; bh=+B0bM5kgjXk4hiYQr8wOE2Rm9RVemz8duU8ugpl4zqw=; b=F25Yk0v2Xf3R9EB8620na776pJypjgiNGXV6yUCAgHY0378XR/7ydWpcJMSBQqFyE6 KMArIj8KUPqBynLTnZo3s4M+YhVeJ5yUZQQoOU+gzP/lG08HfCadl0k1yyJ968bxX14P U5Zn1q/prko/mtylk2MKLYMILp1jmoW6J5q3r/zcgivXhD6u2e1FAb5OQ3lzYMgXnDWp CnclrbAomimUZPG3SPRt0QtCd0yixn71IPTS0c4PxoCMHhOMoIIAVoWIHus1VhyLKIt2 fPpBLJg/NKDGPrM0JGR4zJXZkQDg96BdLXB5hrLAwqgRmXhoNyzhLvNCaI1V/E5Tt/cF BIvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=V6ULbkcW; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d17si20376054pfj.373.2021.10.17.20.44.36; Sun, 17 Oct 2021 20:44:48 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=V6ULbkcW; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242446AbhJQNwY (ORCPT + 98 others); Sun, 17 Oct 2021 09:52:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:56102 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230400AbhJQNwY (ORCPT ); Sun, 17 Oct 2021 09:52:24 -0400 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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