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 <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>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
Bingbu Cao 2020-11-27 04:48:12 +01:00 committed by Mauro Carvalho Chehab
parent 989bea4891
commit 9677958d1d
1 changed files with 5 additions and 3 deletions

View File

@ -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)
return 0;
mutex_lock(&ov9734->mutex);
if (ov9734->streaming == enable) {
mutex_unlock(&ov9734->mutex);
return 0;
}
if (enable) {
ret = pm_runtime_get_sync(&client->dev);
if (ret < 0) {