dmaengine: ioatdma: Fix leaking on version mismatch
[ Upstream commit 1b11b4ef6bd68591dcaf8423c7d05e794e6aec6f ] Fix leaking ioatdma_device if I/OAT version is less than IOAT_VER_3_0. Fixes: bf453a0a18b2 ("dmaengine: ioat: Support in-use unbind") Signed-off-by: Nikita Shubin <n.shubin@yadro.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Link: https://lore.kernel.org/r/20240528-ioatdma-fixes-v2-1-a9f2fbe26ab1@yadro.com Signed-off-by: Vinod Koul <vkoul@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
806ad3dadf
commit
770502584e
1 changed files with 10 additions and 7 deletions
|
@ -1349,6 +1349,7 @@ static int ioat_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
||||||
void __iomem * const *iomap;
|
void __iomem * const *iomap;
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
struct ioatdma_device *device;
|
struct ioatdma_device *device;
|
||||||
|
u8 version;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = pcim_enable_device(pdev);
|
err = pcim_enable_device(pdev);
|
||||||
|
@ -1362,6 +1363,10 @@ static int ioat_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
||||||
if (!iomap)
|
if (!iomap)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
version = readb(iomap[IOAT_MMIO_BAR] + IOAT_VER_OFFSET);
|
||||||
|
if (version < IOAT_VER_3_0)
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
|
err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
|
||||||
if (err)
|
if (err)
|
||||||
err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
|
err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
|
||||||
|
@ -1374,16 +1379,14 @@ static int ioat_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
||||||
pci_set_master(pdev);
|
pci_set_master(pdev);
|
||||||
pci_set_drvdata(pdev, device);
|
pci_set_drvdata(pdev, device);
|
||||||
|
|
||||||
device->version = readb(device->reg_base + IOAT_VER_OFFSET);
|
device->version = version;
|
||||||
if (device->version >= IOAT_VER_3_4)
|
if (device->version >= IOAT_VER_3_4)
|
||||||
ioat_dca_enabled = 0;
|
ioat_dca_enabled = 0;
|
||||||
if (device->version >= IOAT_VER_3_0) {
|
|
||||||
if (is_skx_ioat(pdev))
|
if (is_skx_ioat(pdev))
|
||||||
device->version = IOAT_VER_3_2;
|
device->version = IOAT_VER_3_2;
|
||||||
err = ioat3_dma_probe(device, ioat_dca_enabled);
|
|
||||||
} else
|
|
||||||
return -ENODEV;
|
|
||||||
|
|
||||||
|
err = ioat3_dma_probe(device, ioat_dca_enabled);
|
||||||
if (err) {
|
if (err) {
|
||||||
dev_err(dev, "Intel(R) I/OAT DMA Engine init failed\n");
|
dev_err(dev, "Intel(R) I/OAT DMA Engine init failed\n");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
Loading…
Add table
Reference in a new issue