Skip to contentSkip to conversation

Add missing call to 'pci_free_irq_vectors()'

PATCH In review Dejin Zheng 3 participants 7 messages Feb 14, 2021 – Feb 15, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover Add missing call to 'pci_free_irq_vectors()'

This patchset just for add missing call to 'pci_free_irq_vectors()' in the error handling path of the probe function, or in the remove function.

Dejin Zheng (3):
dmaengine: hsu: Add missing call to 'pci_free_irq_vectors()' in probe
and remove functions
dmaengine: dw-edma: Add missing call to 'pci_free_irq_vectors()' in
probe function
dmaengine: hisilicon: Add missing call to 'pci_free_irq_vectors()' in
probe function

 drivers/dma/dw-edma/dw-edma-pcie.c | 15 +++++++++++----
 drivers/dma/hisi_dma.c             | 14 ++++++++++----
 drivers/dma/hsu/pci.c              |  5 ++++-
 3 files changed, 25 insertions(+), 9 deletions(-)
Signature · 1 line
2.25.0
#1 lore raw

PATCH 1/3 dmaengine: hsu: Add missing call to 'pci_free_irq_vectors()' in probe and remove functions

Call to 'pci_free_irq_vectors()' are missing both in the error handling path of the probe function, and in the remove function.
Add them.

Fixes e9bb8a9df316a2 ("dmaengine: hsu: pci: switch to new API for IRQ allocation")
---
 drivers/dma/hsu/pci.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/dma/hsu/pci.c +4 -1
index 9045a6f7f589..b335e2ef795b 100644
@@ -89,7 +89,7 @@ static int hsu_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
 	ret = hsu_dma_probe(chip);
 	if (ret)
-		return ret;
+		goto err_irq_vectors;
 
 	ret = request_irq(chip->irq, hsu_pci_irq, 0, "hsu_dma_pci", chip);
 	if (ret)
@@ -112,6 +112,8 @@ static int hsu_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
 err_register_irq:
 	hsu_dma_remove(chip);
+err_irq_vectors:
+	pci_free_irq_vectors(pdev);
 	return ret;
 }
 
@@ -121,6 +123,7 @@ static void hsu_pci_remove(struct pci_dev *pdev)
 
 	free_irq(chip->irq, chip);
 	hsu_dma_remove(chip);
+	pci_free_irq_vectors(pdev);
 }
 
 static const struct pci_device_id hsu_pci_id_table[] = {
Signature · 1 line
2.25.0
#2 lore raw

Re: [PATCH 1/3] dmaengine: hsu: Add missing call to 'pci_free_irq_vectors()' in probe and remove functions

Quoted 6 lines · Dejin Zheng

Call to 'pci_free_irq_vectors()' are missing both in the error handling path of the probe function, and in the remove function.
Add them.

Fixes e9bb8a9df316a2 ("dmaengine: hsu: pci: switch to new API for IRQ allocation")

Same as per others. This does not fix anything, because there is no issue. If you want to have it better, introduce a pcim_alloc_irq_vectors() to show that it's managed.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw

PATCH 2/3 dmaengine: dw-edma: Add missing call to 'pci_free_irq_vectors()' in probe function

In reply to Dejin Zheng

Call to 'pci_free_irq_vectors()' is missing in the error handling path of the probe function, So add it.

Fixes 41aaff2a2ac01c5 ("dmaengine: Add Synopsys eDMA IP PCIe glue-logic")
---
 drivers/dma/dw-edma/dw-edma-pcie.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/dma/dw-edma/dw-edma-pcie.c +11 -4
index 1eafc602e17e..c1e796bd3ee9 100644
@@ -185,24 +185,31 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev,
 	/* Validating if PCI interrupts were enabled */
 	if (!pci_dev_msi_enabled(pdev)) {
 		pci_err(pdev, "enable interrupt failed\n");
-		return -EPERM;
+		err = -EPERM;
+		goto err_free_irq;
 	}
 
 	dw->irq = devm_kcalloc(dev, nr_irqs, sizeof(*dw->irq), GFP_KERNEL);
-	if (!dw->irq)
-		return -ENOMEM;
+	if (!dw->irq) {
+		err = -ENOMEM;
+		goto err_free_irq;
+	}
 
 	/* Starting eDMA driver */
 	err = dw_edma_probe(chip);
 	if (err) {
 		pci_err(pdev, "eDMA probe failed\n");
-		return err;
+		goto err_free_irq;
 	}
 
 	/* Saving data structure reference */
 	pci_set_drvdata(pdev, chip);
 
 	return 0;
+
+err_free_irq:
+	pci_free_irq_vectors(pdev);
+	return err;
 }
 
 static void dw_edma_pcie_remove(struct pci_dev *pdev)
Signature · 1 line
2.25.0
Acked-by on v1 2/3
#4 lore raw

RE: [PATCH 2/3] dmaengine: dw-edma: Add missing call to 'pci_free_irq_vectors()' in probe function

Quoted 51 lines · Dejin Zheng

Call to 'pci_free_irq_vectors()' is missing in the error handling path of the probe function, So add it.

Fixes 41aaff2a2ac01c5 ("dmaengine: Add Synopsys eDMA IP PCIe glue-logic")
---
 drivers/dma/dw-edma/dw-edma-pcie.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/dma/dw-edma/dw-edma-pcie.c +11 -4
index 1eafc602e17e..c1e796bd3ee9 100644
@@ -185,24 +185,31 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev,
 	/* Validating if PCI interrupts were enabled */
 	if (!pci_dev_msi_enabled(pdev)) {
 		pci_err(pdev, "enable interrupt failed\n");
-		return -EPERM;
+		err = -EPERM;
+		goto err_free_irq;
 	}
 
 	dw->irq = devm_kcalloc(dev, nr_irqs, sizeof(*dw->irq), GFP_KERNEL);
-	if (!dw->irq)
-		return -ENOMEM;
+	if (!dw->irq) {
+		err = -ENOMEM;
+		goto err_free_irq;
+	}
 
 	/* Starting eDMA driver */
 	err = dw_edma_probe(chip);
 	if (err) {
 		pci_err(pdev, "eDMA probe failed\n");
-		return err;
+		goto err_free_irq;
 	}
 
 	/* Saving data structure reference */
 	pci_set_drvdata(pdev, chip);
 
 	return 0;
+
+err_free_irq:
+	pci_free_irq_vectors(pdev);
+	return err;
 }
 
 static void dw_edma_pcie_remove(struct pci_dev *pdev)
Signature · 1 line
2.25.0
#5 lore raw

Re: [PATCH 2/3] dmaengine: dw-edma: Add missing call to 'pci_free_irq_vectors()' in probe function

Quoted 51 lines · Gustavo Pimentel
Quoted 48 lines · Dejin Zheng

Call to 'pci_free_irq_vectors()' is missing in the error handling path of the probe function, So add it.

Fixes 41aaff2a2ac01c5 ("dmaengine: Add Synopsys eDMA IP PCIe glue-logic")
---
 drivers/dma/dw-edma/dw-edma-pcie.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/dma/dw-edma/dw-edma-pcie.c +11 -4
index 1eafc602e17e..c1e796bd3ee9 100644
@@ -185,24 +185,31 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev,
 	/* Validating if PCI interrupts were enabled */
 	if (!pci_dev_msi_enabled(pdev)) {
 		pci_err(pdev, "enable interrupt failed\n");
-		return -EPERM;
+		err = -EPERM;
+		goto err_free_irq;
 	}
 
 	dw->irq = devm_kcalloc(dev, nr_irqs, sizeof(*dw->irq), GFP_KERNEL);
-	if (!dw->irq)
-		return -ENOMEM;
+	if (!dw->irq) {
+		err = -ENOMEM;
+		goto err_free_irq;
+	}
 
 	/* Starting eDMA driver */
 	err = dw_edma_probe(chip);
 	if (err) {
 		pci_err(pdev, "eDMA probe failed\n");
-		return err;
+		goto err_free_irq;
 	}
 
 	/* Saving data structure reference */
 	pci_set_drvdata(pdev, chip);
 
 	return 0;
+
+err_free_irq:
+	pci_free_irq_vectors(pdev);
+	return err;
 }
 
Quoted 7 lines
Quoted 3 lines
drivers/dma/dw-edma/dw-edma-pcie.c +0 -0
 static void dw_edma_pcie_remove(struct pci_dev *pdev)
Signature · 1 line
2.25.0

Gustavo, Thanks!

Dejin

#6 lore raw

PATCH 3/3 dmaengine: hisilicon: Add missing call to 'pci_free_irq_vectors()' in probe function

In reply to Dejin Zheng

Call to 'pci_free_irq_vectors()' is missing in the error handling path of the probe function, So add it.

Fixes e9f08b65250d73ab ("dmaengine: hisilicon: Add Kunpeng DMA engine support")
---
 drivers/dma/hisi_dma.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/dma/hisi_dma.c +10 -4
index a259ee010e9b..9e894d7f5dab 100644
@@ -553,7 +553,7 @@ static int hisi_dma_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
 	ret = devm_add_action_or_reset(dev, hisi_dma_free_irq_vectors, pdev);
 	if (ret)
-		return ret;
+		goto err_free_irq;
 
 	dma_dev = &hdma_dev->dma_dev;
 	dma_cap_set(DMA_MEMCPY, dma_dev->cap_mask);
@@ -572,18 +572,24 @@ static int hisi_dma_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	ret = hisi_dma_enable_hw_channels(hdma_dev);
 	if (ret < 0) {
 		dev_err(dev, "failed to enable hw channel!\n");
-		return ret;
+		goto err_free_irq;
 	}
 
 	ret = devm_add_action_or_reset(dev, hisi_dma_disable_hw_channels,
 				       hdma_dev);
 	if (ret)
-		return ret;
+		goto err_free_irq;
 
 	ret = dmaenginem_async_device_register(dma_dev);
-	if (ret < 0)
+	if (ret < 0) {
 		dev_err(dev, "failed to register device!\n");
+		goto err_free_irq;
+	}
+
+	return ret;
 
+err_free_irq:
+	pci_free_irq_vectors(pdev);
 	return ret;
 }
 
Signature · 1 line
2.25.0