From: sashiko-bot@kernel.org
To: "Dave Stevenson" <dave.stevenson@raspberrypi.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org,
media-ci@linuxtv.org
Subject: Re: [PATCH v3 01/14] media: imx678: Rework into generic Starvis 2 sensor driver.
Date: Wed, 14 Oct 2026 18:11:21 +0000 [thread overview]
Message-ID: <sashiko-outbox-171674@kernel.org> (raw)
In-Reply-To: <20261014-media-starvis2-v3-1-c958362b5d06@raspberrypi.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] media: UAF of active_state due to unsafe cleanup ordering in remove()
- [Low] media: sony-starvis2: sensor left active after identify
--
commit baf6081a4a9848a2866e87a317711ee36642f79e
Author: Dave Stevenson <dave.stevenson@raspberrypi.com>
media: imx678: Rework into generic Starvis 2 sensor driver.
The register layout and programming model for multiple of the
Sony Starvis2 sensors is identical, so prepare for supporting
those by renaming all common parts of the driver to a starvis2_
prefix, and renaming the driver.
> diff --git a/drivers/media/i2c/imx678.c b/drivers/media/i2c/sony-starvis2.c
> index 8413fd44d6575..b4733990d03a7 100644
> --- a/drivers/media/i2c/imx678.c
> +++ b/drivers/media/i2c/sony-starvis2.c
[ ... ]
> @@ -1078,10 +1103,10 @@ static int imx678_identify_model(struct imx678 *imx678)
> * This sensor's ID registers become accessible 80ms after coming out
> * of STANDBY mode.
> */
> - cci_write(imx678->cci, IMX678_REG_MODE_SELECT, 0, &ret);
> - fsleep(IMX678_MODULE_ID_DELAY);
> + cci_write(starvis2->cci, STARVIS2_REG_MODE_SELECT, 0, &ret);
> + fsleep(STARVIS2_MODULE_ID_DELAY);
[Severity: Low]
In starvis2_identify_model(), the sensor is woken from standby by writing 0 to
STARVIS2_REG_MODE_SELECT to read the chip ID. However, the driver never writes
STARVIS2_MODE_STANDBY (1) back to the register before returning.
While pm_runtime_idle() in probe() will normally power off the regulators
entirely, if runtime PM is disabled in the kernel (CONFIG_PM=n) or the
device's power state is forced 'on' by userspace, the regulators will remain
on.
Without reverting to standby mode, the sensor could remain active indefinitely
after probe, unnecessarily consuming power. Should a write to return to
standby mode be added before the function returns?
[ ... ]
> @@ -1380,45 +1407,45 @@ static int imx678_probe(struct i2c_client *client)
[ ... ]
> -static void imx678_remove(struct i2c_client *client)
> +static void starvis2_remove(struct i2c_client *client)
> {
> struct v4l2_subdev *sd = i2c_get_clientdata(client);
> - struct imx678 *imx678 = to_imx678(sd);
> + struct starvis2 *starvis2 = to_starvis2(sd);
>
> v4l2_async_unregister_subdev(sd);
> v4l2_subdev_cleanup(sd);
> media_entity_cleanup(&sd->entity);
> - v4l2_ctrl_handler_free(imx678->sd.ctrl_handler);
> + v4l2_ctrl_handler_free(starvis2->sd.ctrl_handler);
[Severity: High]
Does this cleanup ordering create a race condition that could lead to a
use-after-free?
v4l2_async_unregister_subdev() unregisters the device node but does not
block currently executing ioctls on open file descriptors. Then,
v4l2_subdev_cleanup() unconditionally frees sd->active_state.
However, v4l2_ctrl_handler_free() (which synchronizes with running ioctls
by taking the handler lock) is called after v4l2_subdev_cleanup().
If a user opens the V4L2 subdevice node and concurrently calls an ioctl like
VIDIOC_S_CTRL, starvis2_set_ctrl() could dereference the freed active_state.
Should v4l2_ctrl_handler_free() be called before v4l2_subdev_cleanup() to
ensure proper synchronization and protect the active state from being freed
while ioctls are still using it?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261014-media-starvis2-v3-0-c958362b5d06@raspberrypi.com?part=1
next prev parent reply other threads:[~2026-10-14 18:11 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-14 17:54 [PATCH v3 00/14] Update imx678 to act as a common Sony Starvis 2 driver Dave Stevenson
2026-10-14 17:54 ` [PATCH v3 01/14] media: imx678: Rework into generic Starvis 2 sensor driver Dave Stevenson
2026-10-14 18:11 ` sashiko-bot [this message]
2026-10-14 17:54 ` [PATCH v3 02/14] media: sony-starvis2: Reorder link frequencies to remove lookup Dave Stevenson
2026-10-14 17:54 ` [PATCH v3 03/14] media: sony-starvis2: Always program the sensor in window mode Dave Stevenson
2026-10-14 17:54 ` [PATCH v3 04/14] media: sony-starvis2: Parameterise the configuration to allow for other models Dave Stevenson
2026-10-14 17:54 ` [PATCH v3 05/14] media: sony-starvis2: Rework 2 lane support for higher link freqs Dave Stevenson
2026-10-14 17:54 ` [PATCH v3 06/14] media: sony-starvis2: Allow runtime control of link frequency Dave Stevenson
2026-10-14 17:54 ` [PATCH v3 07/14] media: sony-starvis2: Correct the exposure range Dave Stevenson
2026-10-14 17:54 ` [PATCH v3 08/14] media: dt-bindings: sony,imx678: Add other Starvis 2 family members Dave Stevenson
2026-10-14 17:54 ` [PATCH v3 09/14] media: sony-starvis2: Add support for IMX662 Dave Stevenson
2026-10-14 17:54 ` [PATCH v3 10/14] media: sony-starvis2: Add support for IMX675 Dave Stevenson
2026-10-14 17:54 ` [PATCH v3 11/14] media: sony-starvis2: Add support for IMX832 Dave Stevenson
2026-10-14 17:54 ` [PATCH v3 12/14] media: sony-starvis2: Only update bits for window mode Dave Stevenson
2026-10-14 17:54 ` [PATCH v3 13/14] media: sony-starvis2: Parameterise exposure min and step Dave Stevenson
2026-10-14 17:54 ` [PATCH v3 14/14] media: sony-starvis2: Add support for IMX585 Dave Stevenson
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=sashiko-outbox-171674@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=dave.stevenson@raspberrypi.com \
--cc=devicetree@vger.kernel.org \
--cc=media-ci@linuxtv.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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