Skip to content

Commit 2f42e05

Browse files
johnstultz-workvinodkoul
authored andcommitted
dmaengine: k3dma: Avoid null pointer traversal
In some cases we seem to submit two transactions in a row, which causes us to lose track of the first. If we then cancel the request, we may still get an interrupt, which traverses a null ds_run value. So try to avoid starting a new transaction if the ds_run value is set. While this patch avoids the null pointer crash, I've had some reports of the k3dma driver still getting confused, which suggests the ds_run/ds_done value handling still isn't quite right. However, I've not run into an issue recently with it so I think this patch is worth pushing upstream to avoid the crash. Signed-off-by: John Stultz <[email protected]> [add ss tag] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent a40c94b commit 2f42e05

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

drivers/dma/k3dma.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,11 @@ static irqreturn_t k3_dma_int_handler(int irq, void *dev_id)
229229
c = p->vchan;
230230
if (c && (tc1 & BIT(i))) {
231231
spin_lock_irqsave(&c->vc.lock, flags);
232-
vchan_cookie_complete(&p->ds_run->vd);
233-
p->ds_done = p->ds_run;
234-
p->ds_run = NULL;
232+
if (p->ds_run != NULL) {
233+
vchan_cookie_complete(&p->ds_run->vd);
234+
p->ds_done = p->ds_run;
235+
p->ds_run = NULL;
236+
}
235237
spin_unlock_irqrestore(&c->vc.lock, flags);
236238
}
237239
if (c && (tc2 & BIT(i))) {
@@ -271,6 +273,10 @@ static int k3_dma_start_txd(struct k3_dma_chan *c)
271273
if (BIT(c->phy->idx) & k3_dma_get_chan_stat(d))
272274
return -EAGAIN;
273275

276+
/* Avoid losing track of ds_run if a transaction is in flight */
277+
if (c->phy->ds_run)
278+
return -EAGAIN;
279+
274280
if (vd) {
275281
struct k3_dma_desc_sw *ds =
276282
container_of(vd, struct k3_dma_desc_sw, vd);

0 commit comments

Comments
 (0)