Skip to content

Commit 1b11b4e

Browse files
maquefelvinodkoul
authored andcommitted
dmaengine: ioatdma: Fix leaking on version mismatch
Fix leaking ioatdma_device if I/OAT version is less than IOAT_VER_3_0. Fixes: bf453a0 ("dmaengine: ioat: Support in-use unbind") 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 ba27e9d commit 1b11b4e

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

drivers/dma/ioat/init.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,6 +1350,7 @@ static int ioat_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
13501350
void __iomem * const *iomap;
13511351
struct device *dev = &pdev->dev;
13521352
struct ioatdma_device *device;
1353+
u8 version;
13531354
int err;
13541355

13551356
err = pcim_enable_device(pdev);
@@ -1363,6 +1364,10 @@ static int ioat_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
13631364
if (!iomap)
13641365
return -ENOMEM;
13651366

1367+
version = readb(iomap[IOAT_MMIO_BAR] + IOAT_VER_OFFSET);
1368+
if (version < IOAT_VER_3_0)
1369+
return -ENODEV;
1370+
13661371
err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
13671372
if (err)
13681373
return err;
@@ -1373,16 +1378,14 @@ static int ioat_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
13731378
pci_set_master(pdev);
13741379
pci_set_drvdata(pdev, device);
13751380

1376-
device->version = readb(device->reg_base + IOAT_VER_OFFSET);
1381+
device->version = version;
13771382
if (device->version >= IOAT_VER_3_4)
13781383
ioat_dca_enabled = 0;
1379-
if (device->version >= IOAT_VER_3_0) {
1380-
if (is_skx_ioat(pdev))
1381-
device->version = IOAT_VER_3_2;
1382-
err = ioat3_dma_probe(device, ioat_dca_enabled);
1383-
} else
1384-
return -ENODEV;
13851384

1385+
if (is_skx_ioat(pdev))
1386+
device->version = IOAT_VER_3_2;
1387+
1388+
err = ioat3_dma_probe(device, ioat_dca_enabled);
13861389
if (err) {
13871390
dev_err(dev, "Intel(R) I/OAT DMA Engine init failed\n");
13881391
return -ENODEV;

0 commit comments

Comments
 (0)