mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kieran Bingham <kieran.bingham@ideasonboard.com>
To: Ginger Li <ginger.jzllee@gmail.com>,
	mchehab@kernel.org, sakari.ailus@linux.intel.com
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] media: i2c: ov5648: Fix a data race on state->streaming
Date: Wed, 23 Sep 2026 15:11:35 +0100	[thread overview]
Message-ID: <179017269592.2497080.16397128200359093970@ping.linuxembedded.co.uk> (raw)
In-Reply-To: <20260923015631.44973-1-ginger.jzllee@gmail.com>

Quoting Ginger Li (2026-09-23 02:56:31)
> ov5648_s_stream() updates state->streaming after it has released
> sensor->mutex, while ov5648_resume() reads that field with sensor->mutex
> held.  A concurrent resume can therefore observe a stale streaming state and
> leave the sensor in standby while the software believes that it is streaming,
> or the other way around.
> 
> Keep the update inside the sensor->mutex protected section that already
> programs the standby mode.
> 
> Fixes: e43ccb0a045f ("media: i2c: Add support for the OV5648 image sensor")
> Signed-off-by: Ginger Li <ginger.jzllee@gmail.com>
> ---
>  drivers/media/i2c/ov5648.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/i2c/ov5648.c b/drivers/media/i2c/ov5648.c
> --- a/drivers/media/i2c/ov5648.c
> +++ b/drivers/media/i2c/ov5648.c
> @@ -2145,12 +2145,12 @@ static int ov5648_s_stream(struct v4l2_subdev *subdev,
>  
>         mutex_lock(&sensor->mutex);
>         ret = ov5648_sw_standby(sensor, !enable);
> +       if (!ret)
> +               state->streaming = !!enable;

I see streaming is accessed in ov5648_suspend and ov5648_resume with the
lock held indeed, so I think this makes sense:


Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

>         mutex_unlock(&sensor->mutex);
>  
>         if (ret)
>                 return ret;
> -
> -       state->streaming = !!enable;
>  
>         if (!enable)
>                 pm_runtime_put(sensor->dev);
> -- 
> 2.43.0
>

      reply	other threads:[~2026-09-23 14:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-23  1:56 Ginger Li
2026-09-23 14:11 ` Kieran Bingham [this message]

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=179017269592.2497080.16397128200359093970@ping.linuxembedded.co.uk \
    --to=kieran.bingham@ideasonboard.com \
    --cc=ginger.jzllee@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --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

all inboxes | Powered by JetHome®