All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mtd: rawnand: fix drivers probe/remove methods
@ 2022-05-17  6:07 ` Peng Wu
  0 siblings, 0 replies; 6+ messages in thread
From: Peng Wu @ 2022-05-17  6:07 UTC (permalink / raw)
  To: miquel.raynal, richard, vigneshr, christophe.jaillet
  Cc: linux-mtd, linux-kernel, liwei391, wupeng58

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.

Signed-off-by: Peng Wu <wupeng58@huawei.com>
---
 drivers/mtd/nand/raw/cafe_nand.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/raw/cafe_nand.c b/drivers/mtd/nand/raw/cafe_nand.c
index 9dbf031716a6..af119e376352 100644
--- a/drivers/mtd/nand/raw/cafe_nand.c
+++ b/drivers/mtd/nand/raw/cafe_nand.c
@@ -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[] = {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH] mtd: rawnand: fix drivers probe/remove methods
@ 2022-05-17  6:07 ` Peng Wu
  0 siblings, 0 replies; 6+ messages in thread
From: Peng Wu @ 2022-05-17  6:07 UTC (permalink / raw)
  To: miquel.raynal, richard, vigneshr, christophe.jaillet
  Cc: linux-mtd, linux-kernel, liwei391, wupeng58

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.

Signed-off-by: Peng Wu <wupeng58@huawei.com>
---
 drivers/mtd/nand/raw/cafe_nand.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/raw/cafe_nand.c b/drivers/mtd/nand/raw/cafe_nand.c
index 9dbf031716a6..af119e376352 100644
--- a/drivers/mtd/nand/raw/cafe_nand.c
+++ b/drivers/mtd/nand/raw/cafe_nand.c
@@ -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[] = {
-- 
2.17.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] mtd: rawnand: fix drivers probe/remove methods
  2022-05-17  6:07 ` Peng Wu
@ 2022-05-19 15:25   ` Miquel Raynal
  -1 siblings, 0 replies; 6+ messages in thread
From: Miquel Raynal @ 2022-05-19 15:25 UTC (permalink / raw)
  To: Peng Wu
  Cc: richard, vigneshr, christophe.jaillet, linux-mtd, linux-kernel, liwei391

Hi,

wupeng58@huawei.com wrote on Tue, 17 May 2022 06:07:53 +0000:

> 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.

> Signed-off-by: Peng Wu <wupeng58@huawei.com>
> ---
>  drivers/mtd/nand/raw/cafe_nand.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/cafe_nand.c b/drivers/mtd/nand/raw/cafe_nand.c
> index 9dbf031716a6..af119e376352 100644
> --- a/drivers/mtd/nand/raw/cafe_nand.c
> +++ b/drivers/mtd/nand/raw/cafe_nand.c
> @@ -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[] = {


Thanks,
Miquèl

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] mtd: rawnand: fix drivers probe/remove methods
@ 2022-05-19 15:25   ` Miquel Raynal
  0 siblings, 0 replies; 6+ messages in thread
From: Miquel Raynal @ 2022-05-19 15:25 UTC (permalink / raw)
  To: Peng Wu
  Cc: richard, vigneshr, christophe.jaillet, linux-mtd, linux-kernel, liwei391

Hi,

wupeng58@huawei.com wrote on Tue, 17 May 2022 06:07:53 +0000:

> 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.

> Signed-off-by: Peng Wu <wupeng58@huawei.com>
> ---
>  drivers/mtd/nand/raw/cafe_nand.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/cafe_nand.c b/drivers/mtd/nand/raw/cafe_nand.c
> index 9dbf031716a6..af119e376352 100644
> --- a/drivers/mtd/nand/raw/cafe_nand.c
> +++ b/drivers/mtd/nand/raw/cafe_nand.c
> @@ -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[] = {


Thanks,
Miquèl

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] mtd: rawnand: fix drivers probe/remove methods
  2022-05-19 15:25   ` Miquel Raynal
@ 2022-05-20  3:33     ` wupeng (D)
  -1 siblings, 0 replies; 6+ messages in thread
From: wupeng (D) @ 2022-05-20  3:33 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: richard, vigneshr, christophe.jaillet, linux-mtd, linux-kernel, liwei391

On 2022/5/19 23:25, Miquel Raynal wrote:
> Hi,
> 
> wupeng58@huawei.com wrote on Tue, 17 May 2022 06:07:53 +0000:
> 
>> 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.
> 
>> Signed-off-by: Peng Wu <wupeng58@huawei.com>
>> ---
>>   drivers/mtd/nand/raw/cafe_nand.c | 9 +++++++--
>>   1 file changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/mtd/nand/raw/cafe_nand.c b/drivers/mtd/nand/raw/cafe_nand.c
>> index 9dbf031716a6..af119e376352 100644
>> --- a/drivers/mtd/nand/raw/cafe_nand.c
>> +++ b/drivers/mtd/nand/raw/cafe_nand.c
>> @@ -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[] = {
> 
> 
> Thanks,
> Miquèl
> .
> 
Hi,
    Thank you very much for correcting the problem and I will fix the unqualified subject name.

Thanks,
Peng Wu

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] mtd: rawnand: fix drivers probe/remove methods
@ 2022-05-20  3:33     ` wupeng (D)
  0 siblings, 0 replies; 6+ messages in thread
From: wupeng (D) @ 2022-05-20  3:33 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: richard, vigneshr, christophe.jaillet, linux-mtd, linux-kernel, liwei391

On 2022/5/19 23:25, Miquel Raynal wrote:
> Hi,
> 
> wupeng58@huawei.com wrote on Tue, 17 May 2022 06:07:53 +0000:
> 
>> 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.
> 
>> Signed-off-by: Peng Wu <wupeng58@huawei.com>
>> ---
>>   drivers/mtd/nand/raw/cafe_nand.c | 9 +++++++--
>>   1 file changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/mtd/nand/raw/cafe_nand.c b/drivers/mtd/nand/raw/cafe_nand.c
>> index 9dbf031716a6..af119e376352 100644
>> --- a/drivers/mtd/nand/raw/cafe_nand.c
>> +++ b/drivers/mtd/nand/raw/cafe_nand.c
>> @@ -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[] = {
> 
> 
> Thanks,
> Miquèl
> .
> 
Hi,
    Thank you very much for correcting the problem and I will fix the unqualified subject name.

Thanks,
Peng Wu

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-05-20  3:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-17  6:07 [PATCH] mtd: rawnand: fix drivers probe/remove methods Peng Wu
2022-05-17  6:07 ` Peng Wu
2022-05-19 15:25 ` Miquel Raynal
2022-05-19 15:25   ` Miquel Raynal
2022-05-20  3:33   ` wupeng (D)
2022-05-20  3:33     ` wupeng (D)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.