From: Pratyush Yadav <p.yadav@ti.com>
To: Mauro Carvalho Chehab <mchehab@kernel.org>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Paul Kocialkowski <paul.kocialkowski@bootlin.com>,
Dan Carpenter <dan.carpenter@oracle.com>,
<linux-media@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: Pratyush Yadav <p.yadav@ti.com>
Subject: [PATCH] media: i2c: ov5648: Plug runtime pm counter leak
Date: Tue, 11 May 2021 18:14:37 +0530 [thread overview]
Message-ID: <20210511124437.9930-1-p.yadav@ti.com> (raw)
When the stream is being enabled, the runtime pm usage counter is
incremented. Then if ov5648_sw_standby() fails, the function returns
error without decrementing the counter, leaking it.
Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
---
Hi,
I spotted this when converting OV5640 driver to use runtime PM using
this driver as reference. I only have a very surface level understanding
of runtime PM system as of now so please review with that in mind.
This patch is only compile-tested since I don't have the hardware with
me.
drivers/media/i2c/ov5648.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/media/i2c/ov5648.c b/drivers/media/i2c/ov5648.c
index 3ecb4a3e8773..6aa2c950f505 100644
--- a/drivers/media/i2c/ov5648.c
+++ b/drivers/media/i2c/ov5648.c
@@ -2143,8 +2143,12 @@ static int ov5648_s_stream(struct v4l2_subdev *subdev, int enable)
ret = ov5648_sw_standby(sensor, !enable);
mutex_unlock(&sensor->mutex);
- if (ret)
+ if (ret) {
+ if (enable)
+ pm_runtime_put(sensor->dev);
+
return ret;
+ }
state->streaming = !!enable;
--
2.30.0
next reply other threads:[~2021-05-11 12:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-11 12:44 Pratyush Yadav [this message]
2021-05-21 14:00 ` [PATCH] media: i2c: ov5648: Plug runtime pm counter leak Sakari Ailus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210511124437.9930-1-p.yadav@ti.com \
--to=p.yadav@ti.com \
--cc=dan.carpenter@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=paul.kocialkowski@bootlin.com \
--cc=sakari.ailus@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).