Skip to content

Commit

Permalink
dmaengine: idxd: fix off by one on cdev dwq refcount
Browse files Browse the repository at this point in the history
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: 42d279f ("dmaengine: idxd: add char driver to expose submission portal to userland")
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/158403020187.10208.14117394394540710774.stgit@djiang5-desk3.ch.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
  • Loading branch information
Dave Jiang authored and Vinod Koul committed Mar 23, 2020
1 parent 195967c commit 988aad2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/dma/idxd/cdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ static int idxd_cdev_open(struct inode *inode, struct file *filp)
dev = &idxd->pdev->dev;
idxd_cdev = &wq->idxd_cdev;

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);
Expand Down

0 comments on commit 988aad2

Please sign in to comment.