Skip to contentSkip to conversation

mtd: rawnand: fix drivers probe/remove methods

PATCH Superseded Peng Wu 2 participants 3 messages May 17, 2022 – May 20, 2022

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Peng Wu

author
#0 lore raw

PATCH 1/1 mtd: rawnand: fix drivers probe/remove methods

Driver should call pci_disable_device() if it returns from cafe_nand_probe() with error.

Meanwhile, the driver calls pci_enable_device() in cafe_nand_probe(), but never calls pci_disable_device() during removal.

---
 drivers/mtd/nand/raw/cafe_nand.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/mtd/nand/raw/cafe_nand.c +7 -2
index 9dbf031716a6..af119e376352 100644
@@ -679,8 +679,10 @@ static int cafe_nand_probe(struct pci_dev *pdev,
 	pci_set_master(pdev);
 
 	cafe = kzalloc(sizeof(*cafe), GFP_KERNEL);
-	if (!cafe)
-		return  -ENOMEM;
+	if (!cafe) {
+		err = -ENOMEM;
+		goto out_disable_device;
+	}
 
 	mtd = nand_to_mtd(&cafe->nand);
 	mtd->dev.parent = &pdev->dev;
@@ -801,6 +803,8 @@ static int cafe_nand_probe(struct pci_dev *pdev,
 	pci_iounmap(pdev, cafe->mmio);
  out_free_mtd:
 	kfree(cafe);
+ out_disable_device:
+	pci_disable_device(pdev);
  out:
 	return err;
 }
@@ -822,6 +826,7 @@ static void cafe_nand_remove(struct pci_dev *pdev)
 	pci_iounmap(pdev, cafe->mmio);
 	dma_free_coherent(&cafe->pdev->dev, 2112, cafe->dmabuf, cafe->dmaaddr);
 	kfree(cafe);
+	pci_disable_device(pdev);
 }
 
 static const struct pci_device_id cafe_nand_tbl[] = {
Signature · 1 line
2.17.1
maintainer
#1 lore raw

Hi,

[email protected] wrote on Tue, 17 May 2022 06:07:53 +0000:

Quoted 6 lines

Driver should call pci_disable_device() if it returns from cafe_nand_probe() with error.

Meanwhile, the driver calls pci_enable_device() in cafe_nand_probe(), but never calls pci_disable_device() during removal.

Please fix the subject prefix, it should be "mtd: ranwnand: cafe:"

Also Fixes/Cc: stable tags might be useful.

Quoted 32 lines
---
 drivers/mtd/nand/raw/cafe_nand.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/mtd/nand/raw/cafe_nand.c +6 -2
index 9dbf031716a6..af119e376352 100644
@@ -679,8 +679,10 @@ static int cafe_nand_probe(struct pci_dev *pdev,
 	pci_set_master(pdev);
 
 	cafe = kzalloc(sizeof(*cafe), GFP_KERNEL);
-	if (!cafe)
-		return  -ENOMEM;
+	if (!cafe) {
+		err = -ENOMEM;
+		goto out_disable_device;
+	}
 
 	mtd = nand_to_mtd(&cafe->nand);
 	mtd->dev.parent = &pdev->dev;
@@ -801,6 +803,8 @@ static int cafe_nand_probe(struct pci_dev *pdev,
 	pci_iounmap(pdev, cafe->mmio);
  out_free_mtd:
 	kfree(cafe);
+ out_disable_device:
+	pci_disable_device(pdev);
  out:
 	return err;
 }

drivers/mtd/nand/raw/cafe_nand.c static void cafe_nand_remove(struct pci_dev *pdev) · line 832

Quoted 7 lines
drivers/mtd/nand/raw/cafe_nand.c +1 -0
@@ -822,6 +826,7 @@ static void cafe_nand_remove(struct pci_dev *pdev)
 	pci_iounmap(pdev, cafe->mmio);
 	dma_free_coherent(&cafe->pdev->dev, 2112, cafe->dmabuf, cafe->dmaaddr);
 	kfree(cafe);
+	pci_disable_device(pdev);
 }
 
 static const struct pci_device_id cafe_nand_tbl[] = {

Thanks,
Miquèl

author
#2 lore raw
Quoted 53 lines · Miquel Raynal

Hi,

[email protected] wrote on Tue, 17 May 2022 06:07:53 +0000:

Quoted 6 lines

Driver should call pci_disable_device() if it returns from cafe_nand_probe() with error.

Meanwhile, the driver calls pci_enable_device() in cafe_nand_probe(), but never calls pci_disable_device() during removal.

Please fix the subject prefix, it should be "mtd: ranwnand: cafe:"

Also Fixes/Cc: stable tags might be useful.

Quoted 38 lines
---
  drivers/mtd/nand/raw/cafe_nand.c | 9 +++++++--
  1 file changed, 7 insertions(+), 2 deletions(-)
drivers/mtd/nand/raw/cafe_nand.c +7 -2
index 9dbf031716a6..af119e376352 100644
@@ -679,8 +679,10 @@ static int cafe_nand_probe(struct pci_dev *pdev,
  	pci_set_master(pdev);
 
  	cafe = kzalloc(sizeof(*cafe), GFP_KERNEL);
-	if (!cafe)
-		return  -ENOMEM;
+	if (!cafe) {
+		err = -ENOMEM;
+		goto out_disable_device;
+	}
 
  	mtd = nand_to_mtd(&cafe->nand);
  	mtd->dev.parent = &pdev->dev;
@@ -801,6 +803,8 @@ static int cafe_nand_probe(struct pci_dev *pdev,
  	pci_iounmap(pdev, cafe->mmio);
   out_free_mtd:
  	kfree(cafe);
+ out_disable_device:
+	pci_disable_device(pdev);
   out:
  	return err;
  }
@@ -822,6 +826,7 @@ static void cafe_nand_remove(struct pci_dev *pdev)
  	pci_iounmap(pdev, cafe->mmio);
  	dma_free_coherent(&cafe->pdev->dev, 2112, cafe->dmabuf, cafe->dmaaddr);
  	kfree(cafe);
+	pci_disable_device(pdev);
  }
 
Quoted 7 lines

drivers/mtd/nand/raw/cafe_nand.c static void cafe_nand_remove(struct pci_dev *pdev) · line 832

Quoted 1 line
drivers/mtd/nand/raw/cafe_nand.c +0 -0
  static const struct pci_device_id cafe_nand_tbl[] = {

Thanks,
Miquèl
.

Hi,
Thank you very much for correcting the problem and I will fix the unqualified subject name.

Thanks,
Peng Wu