Skip to content

Commit 6247cdc

Browse files
committed
async_tx: fix dma_wait_for_async_tx
Fix dma_wait_for_async_tx to not loop forever in the case where a dependency chain is longer than two entries. This condition will not happen with current in-kernel drivers, but fix it for future drivers. Found-by: Saeed Bishara <saeed.bishara@gmail.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent c5d2b9f commit 6247cdc

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

‎crypto/async_tx/async_tx.c‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,23 @@ dma_wait_for_async_tx(struct dma_async_tx_descriptor *tx)
8080
{
8181
enum dma_status status;
8282
struct dma_async_tx_descriptor *iter;
83+
struct dma_async_tx_descriptor *parent;
8384

8485
if (!tx)
8586
return DMA_SUCCESS;
8687

8788
/* poll through the dependency chain, return when tx is complete */
8889
do {
8990
iter = tx;
90-
while (iter->cookie == -EBUSY)
91-
iter = iter->parent;
91+
92+
/* find the root of the unsubmitted dependency chain */
93+
while (iter->cookie == -EBUSY) {
94+
parent = iter->parent;
95+
if (parent && parent->cookie == -EBUSY)
96+
iter = iter->parent;
97+
else
98+
break;
99+
}
92100

93101
status = dma_sync_wait(iter->chan, iter->cookie);
94102
} while (status == DMA_IN_PROGRESS || (iter != tx));

0 commit comments

Comments
 (0)