From: Bingbu Cao Date: Fri, 27 Nov 2020 03:48:12 +0000 (+0100) Subject: media: ov9734: hold lock to check streaming state X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=9677958d1d3d21923ca26cb5e989edc18ecf2786;p=linux.git media: ov9734: hold lock to check streaming state 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 Reported-by: Sergey Senozhatsky Signed-off-by: Bingbu Cao Reviewed-by: Sergey Senozhatsky Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/i2c/ov9734.c b/drivers/media/i2c/ov9734.c index 4b9a2e9288e7c..e212465489e8f 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) {