Skip to content

Commit 5613970

Browse files
committed
Merge tag 'dmaengine-fix-5.5-rc5' of git://git.infradead.org/users/vkoul/slave-dma
Pull dmaengine fixes from Vinod Koul: "A bunch of fixes for: - uninitialized dma_slave_caps access - virt-dma use after free in vchan_complete() - driver fixes for ioat, k3dma and jz4780" * tag 'dmaengine-fix-5.5-rc5' of git://git.infradead.org/users/vkoul/slave-dma: ioat: ioat_alloc_ring() failure handling. dmaengine: virt-dma: Fix access after free in vchan_complete() dmaengine: k3dma: Avoid null pointer traversal dmaengine: dma-jz4780: Also break descriptor chains on JZ4725B dmaengine: Fix access to uninitialized dma_slave_caps
2 parents 50978df + b0b5ce1 commit 5613970

File tree

5 files changed

+18
-8
lines changed

5 files changed

+18
-8
lines changed

drivers/dma/dma-jz4780.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,8 @@ static const struct jz4780_dma_soc_data jz4740_dma_soc_data = {
999999
static const struct jz4780_dma_soc_data jz4725b_dma_soc_data = {
10001000
.nb_channels = 6,
10011001
.transfer_ord_max = 5,
1002-
.flags = JZ_SOC_DATA_PER_CHAN_PM | JZ_SOC_DATA_NO_DCKES_DCKEC,
1002+
.flags = JZ_SOC_DATA_PER_CHAN_PM | JZ_SOC_DATA_NO_DCKES_DCKEC |
1003+
JZ_SOC_DATA_BREAK_LINKS,
10031004
};
10041005

10051006
static const struct jz4780_dma_soc_data jz4770_dma_soc_data = {

drivers/dma/ioat/dma.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,10 +377,11 @@ ioat_alloc_ring(struct dma_chan *c, int order, gfp_t flags)
377377

378378
descs->virt = dma_alloc_coherent(to_dev(ioat_chan),
379379
SZ_2M, &descs->hw, flags);
380-
if (!descs->virt && (i > 0)) {
380+
if (!descs->virt) {
381381
int idx;
382382

383383
for (idx = 0; idx < i; idx++) {
384+
descs = &ioat_chan->descs[idx];
384385
dma_free_coherent(to_dev(ioat_chan), SZ_2M,
385386
descs->virt, descs->hw);
386387
descs->virt = NULL;

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

drivers/dma/virt-dma.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,8 @@ static void vchan_complete(unsigned long arg)
104104
dmaengine_desc_get_callback(&vd->tx, &cb);
105105

106106
list_del(&vd->node);
107-
vchan_vdesc_fini(vd);
108-
109107
dmaengine_desc_callback_invoke(&cb, &vd->tx_result);
108+
vchan_vdesc_fini(vd);
110109
}
111110
}
112111

include/linux/dmaengine.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1364,8 +1364,11 @@ static inline int dma_get_slave_caps(struct dma_chan *chan,
13641364
static inline int dmaengine_desc_set_reuse(struct dma_async_tx_descriptor *tx)
13651365
{
13661366
struct dma_slave_caps caps;
1367+
int ret;
13671368

1368-
dma_get_slave_caps(tx->chan, &caps);
1369+
ret = dma_get_slave_caps(tx->chan, &caps);
1370+
if (ret)
1371+
return ret;
13691372

13701373
if (caps.descriptor_reuse) {
13711374
tx->flags |= DMA_CTRL_REUSE;

0 commit comments

Comments
 (0)