linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] Input: stmfts: fix ref count leak in stmfts_input_open
@ 2020-06-14  9:33 Markus Elfring
  0 siblings, 0 replies; 2+ messages in thread
From: Markus Elfring @ 2020-06-14  9:33 UTC (permalink / raw)
  To: Navid Emamdoost, linux-arm-kernel, linux-input, linux-stm32
  Cc: Navid Emamdoost, Kangjie Lu, Stephen McCamant, Qiushi Wu,
	Alexandre Torgue, Dmitry Torokhov, Maxime Coquelin,
	kernel-janitors, linux-kernel

> in stmfts_input_open, …

* Can the term “reference count” become relevant also for this commit message
  besides other possible adjustments?

* Would you like to add the tag “Fixes”?


…
> +++ b/drivers/input/touchscreen/stmfts.c
> @@ -367,6 +367,9 @@  static int stmfts_input_open(struct input_dev *dev)
>  	}
>
>  	return 0;
> +out:
> +	pm_runtime_put(&sdata->client->dev);
> +	return err;
>  }
…

Perhaps use the label “put_runtime” instead?

Regards,
Markus

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

* [PATCH] Input: stmfts: fix ref count leak in stmfts_input_open
@ 2020-06-14  6:18 Navid Emamdoost
  0 siblings, 0 replies; 2+ messages in thread
From: Navid Emamdoost @ 2020-06-14  6:18 UTC (permalink / raw)
  To: Dmitry Torokhov, Maxime Coquelin, Alexandre Torgue,
	Navid Emamdoost, linux-input, linux-stm32, linux-arm-kernel,
	linux-kernel
  Cc: emamd001, wu000273, kjlu, smccaman

in stmfts_input_open, pm_runtime_get_sync is called which
increments the counter even in case of failure, leading to incorrect
ref count. In case of failure, decrement the ref count before returning.

Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
 drivers/input/touchscreen/stmfts.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/stmfts.c b/drivers/input/touchscreen/stmfts.c
index b6f95f20f924..1ef282d7cc14 100644
--- a/drivers/input/touchscreen/stmfts.c
+++ b/drivers/input/touchscreen/stmfts.c
@@ -339,11 +339,11 @@ static int stmfts_input_open(struct input_dev *dev)
 
 	err = pm_runtime_get_sync(&sdata->client->dev);
 	if (err < 0)
-		return err;
+		goto out;
 
 	err = i2c_smbus_write_byte(sdata->client, STMFTS_MS_MT_SENSE_ON);
 	if (err)
-		return err;
+		goto out;
 
 	mutex_lock(&sdata->mutex);
 	sdata->running = true;
@@ -367,6 +367,9 @@ static int stmfts_input_open(struct input_dev *dev)
 	}
 
 	return 0;
+out:
+	pm_runtime_put(&sdata->client->dev);
+	return err;
 }
 
 static void stmfts_input_close(struct input_dev *dev)
-- 
2.17.1


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

end of thread, other threads:[~2020-06-14  9:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-14  9:33 [PATCH] Input: stmfts: fix ref count leak in stmfts_input_open Markus Elfring
  -- strict thread matches above, loose matches on Subject: below --
2020-06-14  6:18 Navid Emamdoost

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