Commit 85f604af authored by Dave Jiang's avatar Dave Jiang Committed by Vinod Koul
Browse files

dmaengine: idxd: move out percpu_ref_exit() to ensure it's outside submission



percpu_ref_tryget_live() is safe to call as long as ref is between init and
exit according to the function comment. Move percpu_ref_exit() so it is
called after the dma channel is no longer valid to ensure this holds true.

Fixes: 93a40a6d ("dmaengine: idxd: add percpu_ref to descriptor submission path")
Suggested-by: default avatarKevin Tian <kevin.tian@intel.com>
Signed-off-by: default avatarDave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/163294293832.914350.10326422026738506152.stgit@djiang5-desk3.ch.intel.com


Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent ae8f13f0
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -427,7 +427,6 @@ void idxd_wq_quiesce(struct idxd_wq *wq)
{
	percpu_ref_kill(&wq->wq_active);
	wait_for_completion(&wq->wq_dead);
	percpu_ref_exit(&wq->wq_active);
}

/* Device control bits */
+2 −0
Original line number Diff line number Diff line
@@ -311,6 +311,7 @@ static int idxd_dmaengine_drv_probe(struct idxd_dev *idxd_dev)

err_dma:
	idxd_wq_quiesce(wq);
	percpu_ref_exit(&wq->wq_active);
err_ref:
	idxd_wq_free_resources(wq);
err_res_alloc:
@@ -329,6 +330,7 @@ static void idxd_dmaengine_drv_remove(struct idxd_dev *idxd_dev)
	idxd_wq_quiesce(wq);
	idxd_unregister_dma_channel(wq);
	__drv_disable_wq(wq);
	percpu_ref_exit(&wq->wq_active);
	idxd_wq_free_resources(wq);
	wq->type = IDXD_WQT_NONE;
	mutex_unlock(&wq->wq_lock);