Skip to content

Commit 5723cc3

Browse files
committed
Merge tag 'dmaengine-fix-6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine
Pull dmaengine fixes from Vinod Koul: "This has a bunch of idxd driver fixes, dmatest revert and bunch of smaller driver fixes: - a bunch of idxd potential mem leak fixes - dmatest revert for waiting for interrupt fix as that causes issue - a couple of ti k3 udma fixes for locking and cap_mask - mediatek deadlock fix and unused variable cleanup fix" * tag 'dmaengine-fix-6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine: dmaengine: mediatek: drop unused variable dmaengine: fsl-edma: Fix return code for unhandled interrupts dmaengine: mediatek: Fix a possible deadlock error in mtk_cqdma_tx_status() dmaengine: idxd: Fix ->poll() return value dmaengine: idxd: Refactor remove call with idxd_cleanup() helper dmaengine: idxd: Add missing idxd cleanup to fix memory leak in remove call dmaengine: idxd: fix memory leak in error handling path of idxd_pci_probe dmaengine: idxd: fix memory leak in error handling path of idxd_alloc dmaengine: idxd: Add missing cleanups in cleanup internals dmaengine: idxd: Add missing cleanup for early error out in idxd_setup_internals dmaengine: idxd: fix memory leak in error handling path of idxd_setup_groups dmaengine: idxd: fix memory leak in error handling path of idxd_setup_engines dmaengine: idxd: fix memory leak in error handling path of idxd_setup_wqs dmaengine: ptdma: Move variable condition check to the first place and remove redundancy dmaengine: idxd: Fix allowing write() from different address spaces dmaengine: ti: k3-udma: Add missing locking dmaengine: ti: k3-udma: Use cap_mask directly from dma_device structure instead of a local copy dmaengine: Revert "dmaengine: dmatest: Fix dmatest waiting less when interrupted" dmaengine: idxd: cdev: Fix uninitialized use of sva in idxd_cdev_open
2 parents 21eeefe + 811d6a9 commit 5723cc3

File tree

7 files changed

+148
-67
lines changed

7 files changed

+148
-67
lines changed

drivers/dma/amd/ptdma/ptdma-dmaengine.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,9 @@ static void pt_cmd_callback_work(void *data, int err)
342342
struct pt_dma_chan *chan;
343343
unsigned long flags;
344344

345+
if (!desc)
346+
return;
347+
345348
dma_chan = desc->vd.tx.chan;
346349
chan = to_pt_chan(dma_chan);
347350

@@ -355,16 +358,14 @@ static void pt_cmd_callback_work(void *data, int err)
355358
desc->status = DMA_ERROR;
356359

357360
spin_lock_irqsave(&chan->vc.lock, flags);
358-
if (desc) {
359-
if (desc->status != DMA_COMPLETE) {
360-
if (desc->status != DMA_ERROR)
361-
desc->status = DMA_COMPLETE;
361+
if (desc->status != DMA_COMPLETE) {
362+
if (desc->status != DMA_ERROR)
363+
desc->status = DMA_COMPLETE;
362364

363-
dma_cookie_complete(tx_desc);
364-
dma_descriptor_unmap(tx_desc);
365-
} else {
366-
tx_desc = NULL;
367-
}
365+
dma_cookie_complete(tx_desc);
366+
dma_descriptor_unmap(tx_desc);
367+
} else {
368+
tx_desc = NULL;
368369
}
369370
spin_unlock_irqrestore(&chan->vc.lock, flags);
370371

drivers/dma/dmatest.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -841,9 +841,9 @@ static int dmatest_func(void *data)
841841
} else {
842842
dma_async_issue_pending(chan);
843843

844-
wait_event_timeout(thread->done_wait,
845-
done->done,
846-
msecs_to_jiffies(params->timeout));
844+
wait_event_freezable_timeout(thread->done_wait,
845+
done->done,
846+
msecs_to_jiffies(params->timeout));
847847

848848
status = dma_async_is_tx_complete(chan, cookie, NULL,
849849
NULL);

drivers/dma/fsl-edma-main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static irqreturn_t fsl_edma3_tx_handler(int irq, void *dev_id)
5757

5858
intr = edma_readl_chreg(fsl_chan, ch_int);
5959
if (!intr)
60-
return IRQ_HANDLED;
60+
return IRQ_NONE;
6161

6262
edma_writel_chreg(fsl_chan, 1, ch_int);
6363

drivers/dma/idxd/cdev.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ static int idxd_cdev_open(struct inode *inode, struct file *filp)
222222
struct idxd_wq *wq;
223223
struct device *dev, *fdev;
224224
int rc = 0;
225-
struct iommu_sva *sva;
225+
struct iommu_sva *sva = NULL;
226226
unsigned int pasid;
227227
struct idxd_cdev *idxd_cdev;
228228

@@ -317,7 +317,7 @@ static int idxd_cdev_open(struct inode *inode, struct file *filp)
317317
if (device_user_pasid_enabled(idxd))
318318
idxd_xa_pasid_remove(ctx);
319319
failed_get_pasid:
320-
if (device_user_pasid_enabled(idxd))
320+
if (device_user_pasid_enabled(idxd) && !IS_ERR_OR_NULL(sva))
321321
iommu_sva_unbind_device(sva);
322322
failed:
323323
mutex_unlock(&wq->wq_lock);
@@ -407,6 +407,9 @@ static int idxd_cdev_mmap(struct file *filp, struct vm_area_struct *vma)
407407
if (!idxd->user_submission_safe && !capable(CAP_SYS_RAWIO))
408408
return -EPERM;
409409

410+
if (current->mm != ctx->mm)
411+
return -EPERM;
412+
410413
rc = check_vma(wq, vma, __func__);
411414
if (rc < 0)
412415
return rc;
@@ -473,6 +476,9 @@ static ssize_t idxd_cdev_write(struct file *filp, const char __user *buf, size_t
473476
ssize_t written = 0;
474477
int i;
475478

479+
if (current->mm != ctx->mm)
480+
return -EPERM;
481+
476482
for (i = 0; i < len/sizeof(struct dsa_hw_desc); i++) {
477483
int rc = idxd_submit_user_descriptor(ctx, udesc + i);
478484

@@ -493,6 +499,9 @@ static __poll_t idxd_cdev_poll(struct file *filp,
493499
struct idxd_device *idxd = wq->idxd;
494500
__poll_t out = 0;
495501

502+
if (current->mm != ctx->mm)
503+
return POLLNVAL;
504+
496505
poll_wait(filp, &wq->err_queue, wait);
497506
spin_lock(&idxd->dev_lock);
498507
if (idxd->sw_err.valid)

0 commit comments

Comments
 (0)