Skip to content

Commit f0dc9fd

Browse files
maquefelvinodkoul
authored andcommitted
dmaengine: ioatdma: Fix error path in ioat3_dma_probe()
Make sure we are disabling interrupts and destroying DMA pool if pcie_capability_read/write_word() call failed. Fixes: 511deae ("dmaengine: ioatdma: disable relaxed ordering for ioatdma") Signed-off-by: Nikita Shubin <[email protected]> Reviewed-by: Dave Jiang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 1b11b4e commit f0dc9fd

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

drivers/dma/ioat/init.c

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -534,18 +534,6 @@ static int ioat_probe(struct ioatdma_device *ioat_dma)
534534
return err;
535535
}
536536

537-
static int ioat_register(struct ioatdma_device *ioat_dma)
538-
{
539-
int err = dma_async_device_register(&ioat_dma->dma_dev);
540-
541-
if (err) {
542-
ioat_disable_interrupts(ioat_dma);
543-
dma_pool_destroy(ioat_dma->completion_pool);
544-
}
545-
546-
return err;
547-
}
548-
549537
static void ioat_dma_remove(struct ioatdma_device *ioat_dma)
550538
{
551539
struct dma_device *dma = &ioat_dma->dma_dev;
@@ -1181,9 +1169,9 @@ static int ioat3_dma_probe(struct ioatdma_device *ioat_dma, int dca)
11811169
ioat_chan->reg_base + IOAT_DCACTRL_OFFSET);
11821170
}
11831171

1184-
err = ioat_register(ioat_dma);
1172+
err = dma_async_device_register(&ioat_dma->dma_dev);
11851173
if (err)
1186-
return err;
1174+
goto err_disable_interrupts;
11871175

11881176
ioat_kobject_add(ioat_dma, &ioat_ktype);
11891177

@@ -1192,20 +1180,29 @@ static int ioat3_dma_probe(struct ioatdma_device *ioat_dma, int dca)
11921180

11931181
/* disable relaxed ordering */
11941182
err = pcie_capability_read_word(pdev, PCI_EXP_DEVCTL, &val16);
1195-
if (err)
1196-
return pcibios_err_to_errno(err);
1183+
if (err) {
1184+
err = pcibios_err_to_errno(err);
1185+
goto err_disable_interrupts;
1186+
}
11971187

11981188
/* clear relaxed ordering enable */
11991189
val16 &= ~PCI_EXP_DEVCTL_RELAX_EN;
12001190
err = pcie_capability_write_word(pdev, PCI_EXP_DEVCTL, val16);
1201-
if (err)
1202-
return pcibios_err_to_errno(err);
1191+
if (err) {
1192+
err = pcibios_err_to_errno(err);
1193+
goto err_disable_interrupts;
1194+
}
12031195

12041196
if (ioat_dma->cap & IOAT_CAP_DPS)
12051197
writeb(ioat_pending_level + 1,
12061198
ioat_dma->reg_base + IOAT_PREFETCH_LIMIT_OFFSET);
12071199

12081200
return 0;
1201+
1202+
err_disable_interrupts:
1203+
ioat_disable_interrupts(ioat_dma);
1204+
dma_pool_destroy(ioat_dma->completion_pool);
1205+
return err;
12091206
}
12101207

12111208
static void ioat_shutdown(struct pci_dev *pdev)

0 commit comments

Comments
 (0)