dmaengine Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v2] dmaengine: idxd: fix off by one on cdev dwq refcount
@ 2020-03-12 16:23 Dave Jiang
  2020-03-23  6:02 ` Vinod Koul
  0 siblings, 1 reply; 2+ messages in thread
From: Dave Jiang @ 2020-03-12 16:23 UTC (permalink / raw)
  To: vkoul; +Cc: dmaengine

The refcount check for dedicated workqueue (dwq) is off by one and allows
more than 1 user to open the char device. Fix check so only a single user
can open the device.

Fixes: 42d279f9137a ("dmaengine: idxd: add char driver to expose submission portal to userland")
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
---

v2: Vinod: Fix spelling error in commit message.

 drivers/dma/idxd/cdev.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/idxd/cdev.c b/drivers/dma/idxd/cdev.c
index d58144eca6e8..ff49847e37a8 100644
--- a/drivers/dma/idxd/cdev.c
+++ b/drivers/dma/idxd/cdev.c
@@ -79,9 +79,9 @@ static int idxd_cdev_open(struct inode *inode, struct file *filp)
 	idxd = wq->idxd;
 	dev = &idxd->pdev->dev;
 
-	dev_dbg(dev, "%s called\n", __func__);
+	dev_dbg(dev, "%s called: %d\n", __func__, idxd_wq_refcount(wq));
 
-	if (idxd_wq_refcount(wq) > 1 && wq_dedicated(wq))
+	if (idxd_wq_refcount(wq) > 0 && wq_dedicated(wq))
 		return -EBUSY;
 
 	ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] dmaengine: idxd: fix off by one on cdev dwq refcount
  2020-03-12 16:23 [PATCH v2] dmaengine: idxd: fix off by one on cdev dwq refcount Dave Jiang
@ 2020-03-23  6:02 ` Vinod Koul
  0 siblings, 0 replies; 2+ messages in thread
From: Vinod Koul @ 2020-03-23  6:02 UTC (permalink / raw)
  To: Dave Jiang; +Cc: dmaengine

On 12-03-20, 09:23, Dave Jiang wrote:
> The refcount check for dedicated workqueue (dwq) is off by one and allows
> more than 1 user to open the char device. Fix check so only a single user
> can open the device.

Applied, thanks

-- 
~Vinod

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-12 16:23 [PATCH v2] dmaengine: idxd: fix off by one on cdev dwq refcount Dave Jiang
2020-03-23  6:02 ` Vinod Koul

dmaengine Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/dmaengine/0 dmaengine/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dmaengine dmaengine/ https://lore.kernel.org/dmaengine \
		dmaengine@vger.kernel.org
	public-inbox-index dmaengine

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.dmaengine


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git