Skip to content

Commit 9d9c288

Browse files
Peter Ujfalusigregkh
authored andcommitted
dmaengine: ti-dma-crossbar: Fix possible race condition with dma_inuse
commit 2ccb483 upstream. When looking for unused xbar_out lane we should also protect the set_bit() call with the same mutex to protect against concurrent threads picking the same ID. Fixes: ec9bfa1 ("dmaengine: ti-dma-crossbar: dra7: Use bitops instead of idr") Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Vinod Koul <vinod.koul@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 618c786 commit 9d9c288

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/dma/ti-dma-crossbar.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,13 +262,14 @@ static void *ti_dra7_xbar_route_allocate(struct of_phandle_args *dma_spec,
262262
mutex_lock(&xbar->mutex);
263263
map->xbar_out = find_first_zero_bit(xbar->dma_inuse,
264264
xbar->dma_requests);
265-
mutex_unlock(&xbar->mutex);
266265
if (map->xbar_out == xbar->dma_requests) {
266+
mutex_unlock(&xbar->mutex);
267267
dev_err(&pdev->dev, "Run out of free DMA requests\n");
268268
kfree(map);
269269
return ERR_PTR(-ENOMEM);
270270
}
271271
set_bit(map->xbar_out, xbar->dma_inuse);
272+
mutex_unlock(&xbar->mutex);
272273

273274
map->xbar_in = (u16)dma_spec->args[0];
274275

0 commit comments

Comments
 (0)