All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] media: ov9734: hold lock to check streaming state
@ 2020-11-27  3:48 Bingbu Cao
  2020-11-27  6:30 ` Sergey Senozhatsky
  0 siblings, 1 reply; 2+ messages in thread
From: Bingbu Cao @ 2020-11-27  3:48 UTC (permalink / raw)
  To: linux-media, sakari.ailus; +Cc: senozhatsky, tfiga, bingbu.cao, bingbu.cao

The lock in ov9734 is used to protect the streaming state and
serialize the stream on and off callbacks, it should be hold before
checking the streaming state in ov9734_set_stream().

Reported-by: Tomasz Figa <tfiga@chromium.org>
Reported-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
---
 drivers/media/i2c/ov9734.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/i2c/ov9734.c b/drivers/media/i2c/ov9734.c
index 4b9a2e9288e7..e212465489e8 100644
--- a/drivers/media/i2c/ov9734.c
+++ b/drivers/media/i2c/ov9734.c
@@ -637,10 +637,12 @@ static int ov9734_set_stream(struct v4l2_subdev *sd, int enable)
 	struct i2c_client *client = v4l2_get_subdevdata(sd);
 	int ret = 0;
 
-	if (ov9734->streaming == enable)
+	mutex_lock(&ov9734->mutex);
+	if (ov9734->streaming == enable) {
+		mutex_unlock(&ov9734->mutex);
 		return 0;
+	}
 
-	mutex_lock(&ov9734->mutex);
 	if (enable) {
 		ret = pm_runtime_get_sync(&client->dev);
 		if (ret < 0) {
-- 
2.7.4


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

* Re: [PATCH] media: ov9734: hold lock to check streaming state
  2020-11-27  3:48 [PATCH] media: ov9734: hold lock to check streaming state Bingbu Cao
@ 2020-11-27  6:30 ` Sergey Senozhatsky
  0 siblings, 0 replies; 2+ messages in thread
From: Sergey Senozhatsky @ 2020-11-27  6:30 UTC (permalink / raw)
  To: Bingbu Cao; +Cc: linux-media, sakari.ailus, senozhatsky, tfiga, bingbu.cao

On (20/11/27 11:48), Bingbu Cao wrote:
> The lock in ov9734 is used to protect the streaming state and
> serialize the stream on and off callbacks, it should be hold before
> checking the streaming state in ov9734_set_stream().
> 
> Reported-by: Tomasz Figa <tfiga@chromium.org>
> Reported-by: Sergey Senozhatsky <senozhatsky@chromium.org>
> Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>

Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>

	-ss

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

end of thread, other threads:[~2020-11-27  6:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-27  3:48 [PATCH] media: ov9734: hold lock to check streaming state Bingbu Cao
2020-11-27  6:30 ` Sergey Senozhatsky

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.