From: Hans de Goede <hansg@kernel.org>
To: Saikiran <bjsaikiran@gmail.com>, linux-media@vger.kernel.org
Cc: bod@kernel.org, sakari.ailus@linux.intel.com, mchehab@kernel.org
Subject: Re: [PATCH] media: i2c: ov02c10: Fix race condition in remove and relax reset timings
Date: Mon, 26 Jan 2026 11:16:16 +0100 [thread overview]
Message-ID: <dd65a573-182e-4517-a264-e2be4b508ac2@kernel.org> (raw)
In-Reply-To: <20260124074402.7165-3-bjsaikiran@gmail.com>
Hi,
On 24-Jan-26 08:43, Saikiran wrote:
> The ov02c10_remove() function has a race condition where v4l2_ctrl_handler
> and media_entity resources are freed before the device is powered off.
> If userspace (e.g., PipeWire/WirePlumber) accesses the device during
> removal, this causes a Use-After-Free leading to kernel oops with
> "Execute from non-executable memory" errors.
>
> Fix by reordering cleanup: disable runtime PM and power off the device
> BEFORE freeing v4l2_ctrl_handler and media_entity resources.
>
> Additionally, relax reset timings to prevent CCI I2C timeout errors.
> The sensor microcontroller occasionally fails to boot within the
> original timing windows, causing "master 1 queue 0 timeout" errors:
> - Assert reset delay: 2ms → 5ms
> - Post-reset boot delay: 5ms → 20ms
>
> These two fixes address different but related stability issues that
> manifest during camera initialization and removal.
>
> Tested-on: Lenovo Yoga Slim 7x (Snapdragon X Elite)
> Signed-off-by: Saikiran <bjsaikiran@gmail.com>
Please split this into 2 separate patches, 1 for the reset
timing change and one for moving the cleanup to after
the poweroff.
Regards,
Hans
> ---
> drivers/media/i2c/ov02c10.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/media/i2c/ov02c10.c b/drivers/media/i2c/ov02c10.c
> index cf93d36032e1..b86cae3d2b74 100644
> --- a/drivers/media/i2c/ov02c10.c
> +++ b/drivers/media/i2c/ov02c10.c
> @@ -692,9 +692,9 @@ static int ov02c10_power_on(struct device *dev)
>
> if (ov02c10->reset) {
> /* Assert reset for at least 2ms on back to back off-on */
> - usleep_range(2000, 2200);
> + usleep_range(5000, 5500);
> gpiod_set_value_cansleep(ov02c10->reset, 0);
> - usleep_range(5000, 5100);
> + usleep_range(20000, 21000);
> }
>
> return 0;
> @@ -864,14 +864,14 @@ static void ov02c10_remove(struct i2c_client *client)
> struct ov02c10 *ov02c10 = to_ov02c10(sd);
>
> v4l2_async_unregister_subdev(sd);
> - v4l2_subdev_cleanup(sd);
> - media_entity_cleanup(&sd->entity);
> - v4l2_ctrl_handler_free(sd->ctrl_handler);
> pm_runtime_disable(ov02c10->dev);
> if (!pm_runtime_status_suspended(ov02c10->dev)) {
> ov02c10_power_off(ov02c10->dev);
> pm_runtime_set_suspended(ov02c10->dev);
> }
> + v4l2_subdev_cleanup(sd);
> + media_entity_cleanup(&sd->entity);
> + v4l2_ctrl_handler_free(sd->ctrl_handler);
> }
>
> static int ov02c10_probe(struct i2c_client *client)
prev parent reply other threads:[~2026-01-26 10:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-24 7:43 [PATCH 0/2] Fix OV02C10 camera color and stability issues Saikiran
2026-01-24 7:43 ` [PATCH] media: i2c: ov02c10: Fix incorrect Bayer pattern to SGRBG10 Saikiran
2026-01-26 10:15 ` Hans de Goede
2026-01-24 7:43 ` [PATCH] media: i2c: ov02c10: Fix race condition in remove and relax reset timings Saikiran
2026-01-26 10:16 ` Hans de Goede [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=dd65a573-182e-4517-a264-e2be4b508ac2@kernel.org \
--to=hansg@kernel.org \
--cc=bjsaikiran@gmail.com \
--cc=bod@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