linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: rawnand: gpmi: fix reference count leak due to pm_runtime_get_sync
@ 2020-06-14  3:43 Aditya Pakki
  2020-06-15  7:24 ` Miquel Raynal
  0 siblings, 1 reply; 2+ messages in thread
From: Aditya Pakki @ 2020-06-14  3:43 UTC (permalink / raw)
  To: pakki001
  Cc: kjlu, wu000273, Han Xu, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, linux-mtd, linux-kernel

On calling pm_runtime_get_sync() the reference count of the device
is incremented. In case of failure, decrement the
reference count before returning the error.

Signed-off-by: Aditya Pakki <pakki001@umn.edu>
---
 drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
index 061a8ddda275..657c0be5c038 100644
--- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
@@ -149,8 +149,10 @@ static int gpmi_init(struct gpmi_nand_data *this)
 	int ret;
 
 	ret = pm_runtime_get_sync(this->dev);
-	if (ret < 0)
+	if (ret < 0) {
+		pm_runtime_put_autosuspend(this->dev);
 		return ret;
+	}
 
 	ret = gpmi_reset_block(r->gpmi_regs, false);
 	if (ret)
@@ -2264,8 +2266,10 @@ static int gpmi_nfc_exec_op(struct nand_chip *chip,
 		this->transfers[i].direction = DMA_NONE;
 
 	ret = pm_runtime_get_sync(this->dev);
-	if (ret < 0)
+	if (ret < 0) {
+		pm_runtime_put_autosuspend(this->dev);
 		return ret;
+	}
 
 	/*
 	 * This driver currently supports only one NAND chip. Plus, dies share
-- 
2.25.1


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

* Re: [PATCH] mtd: rawnand: gpmi: fix reference count leak due to pm_runtime_get_sync
  2020-06-14  3:43 [PATCH] mtd: rawnand: gpmi: fix reference count leak due to pm_runtime_get_sync Aditya Pakki
@ 2020-06-15  7:24 ` Miquel Raynal
  0 siblings, 0 replies; 2+ messages in thread
From: Miquel Raynal @ 2020-06-15  7:24 UTC (permalink / raw)
  To: Aditya Pakki
  Cc: kjlu, wu000273, Han Xu, Richard Weinberger, Vignesh Raghavendra,
	linux-mtd, linux-kernel

Hi Aditya,

Aditya Pakki <pakki001@umn.edu> wrote on Sat, 13 Jun 2020 22:43:00
-0500:

> On calling pm_runtime_get_sync() the reference count of the device
> is incremented. In case of failure, decrement the
> reference count before returning the error.
> 
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>

Missing Fixes/Stable tags here I guess?

> ---
>  drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
> index 061a8ddda275..657c0be5c038 100644
> --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
> +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
> @@ -149,8 +149,10 @@ static int gpmi_init(struct gpmi_nand_data *this)
>  	int ret;
>  
>  	ret = pm_runtime_get_sync(this->dev);
> -	if (ret < 0)
> +	if (ret < 0) {
> +		pm_runtime_put_autosuspend(this->dev);
>  		return ret;
> +	}
>  
>  	ret = gpmi_reset_block(r->gpmi_regs, false);
>  	if (ret)
> @@ -2264,8 +2266,10 @@ static int gpmi_nfc_exec_op(struct nand_chip *chip,
>  		this->transfers[i].direction = DMA_NONE;
>  
>  	ret = pm_runtime_get_sync(this->dev);
> -	if (ret < 0)
> +	if (ret < 0) {
> +		pm_runtime_put_autosuspend(this->dev);
>  		return ret;
> +	}
>  
>  	/*
>  	 * This driver currently supports only one NAND chip. Plus, dies share

Thanks,
Miquèl

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

end of thread, other threads:[~2020-06-15  7:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-14  3:43 [PATCH] mtd: rawnand: gpmi: fix reference count leak due to pm_runtime_get_sync Aditya Pakki
2020-06-15  7:24 ` Miquel Raynal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).