From: sashiko-bot@kernel.org
To: "Dave Stevenson" <dave.stevenson@raspberrypi.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH v3 15/20] media: imx355: Define the exposure offset, and use that define
Date: Wed, 08 Jul 2026 15:07:20 +0000 [thread overview]
Message-ID: <20260708150721.4BEE01F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260708-media-imx355-v3-15-9df386a623d7@raspberrypi.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] The check `!pm_runtime_get_if_in_use(imx355->dev)` incorrectly treats `-EINVAL` as success, causing the driver to write to hardware that is likely powered off and perform an unbalanced `pm_runtime_put()`.
- [High] When switching frame formats, the maximum exposure limit might fail to update to the new mode's geometry if the new format's `vblank_def` matches the current `vblank` value.
--
--- Patch [15]: [PATCH v3 15/20] media: imx355: Define the exposure offset, and use that define ---
commit 271b8bad9a7b25d1cb2eae62528be12497b83823
Author: Dave Stevenson <dave.stevenson@raspberrypi.com>
media: imx355: Define the exposure offset, and use that define
This commit introduces a new define, IMX355_EXPOSURE_OFFSET, to represent
the 10-line difference between frame length and maximum exposure time. It
replaces the bare value of 10 in the driver's control calculations with
this new define.
> diff --git a/drivers/media/i2c/imx355.c b/drivers/media/i2c/imx355.c
> index 2bf8da7469fe5..3b86bd2e2e5e8 100644
> --- a/drivers/media/i2c/imx355.c
> +++ b/drivers/media/i2c/imx355.c
[ ... ]
> @@ -635,7 +636,7 @@ static int imx355_set_ctrl(struct v4l2_ctrl *ctrl)
> switch (ctrl->id) {
> case V4L2_CID_VBLANK:
> /* Update max exposure while meeting expected vblanking */
> - max = imx355->cur_mode->height + ctrl->val - 10;
> + max = imx355->cur_mode->height + ctrl->val - IMX355_EXPOSURE_OFFSET;
> __v4l2_ctrl_modify_range(imx355->exposure,
> imx355->exposure->minimum,
> max, imx355->exposure->step, max);
> break;
> }
>
> /*
> * Applying V4L2 control value only happens
> * when power is up for streaming
> */
> if (!pm_runtime_get_if_in_use(imx355->dev))
> return 0;
[Severity: High]
This is a pre-existing issue, but does this correctly handle negative return
values?
If pm_runtime_get_if_in_use() returns -EINVAL (which occurs when PM runtime
is disabled or during driver unbind), the driver evaluates !(-EINVAL) as
false (0).
This bypasses the early return, leading to I2C writes to potentially
powered-off hardware, followed by a pm_runtime_put() that drops the usage
counter without a corresponding get. This unbalanced put can cause the
device usage count to prematurely reach 0 while other components hold
references.
[Severity: High]
This isn't a bug introduced by this patch, but does the exposure limit
correctly update when changing frame formats?
drivers/media/i2c/imx355.c:imx355_set_pad_format() {
...
__v4l2_ctrl_modify_range(imx355->vblank, IMX355_VBLANK_MIN,
height, 1, vblank_def);
__v4l2_ctrl_s_ctrl(imx355->vblank, vblank_def);
...
}
The driver relies on __v4l2_ctrl_s_ctrl() to trigger the vblank s_ctrl
callback (imx355_set_ctrl) to update the exposure maximum limit based on
the new mode's geometry.
However, if the new format's default vblank_def happens to equal the
currently set vblank value, the V4L2 framework considers the control
unchanged and short-circuits the callback. As a result, the exposure
maximum limit is not updated, potentially allowing users to set an exposure
time that exceeds the frame length.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com?part=15
next prev parent reply other threads:[~2026-07-08 15:07 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-08 14:48 [PATCH v3 00/20] media/imx355: General code cleanups, and adding support for 2 lane operation Dave Stevenson
2026-07-08 14:48 ` [PATCH v3 01/20] media: i2c: imx355: Add support for 24 MHz external clock Dave Stevenson
2026-07-08 14:48 ` [PATCH v3 02/20] dt-bindings: media: imx355: Allow 2 CSI2 data lane output Dave Stevenson
2026-07-08 14:48 ` [PATCH v3 03/20] media: imx355: Remove duplicated registers from the mode tables Dave Stevenson
2026-07-08 15:00 ` sashiko-bot
2026-07-08 14:48 ` [PATCH v3 04/20] media: imx355: Remove setting FRM_LENGTH_LINES in the mode regs Dave Stevenson
2026-07-08 14:48 ` [PATCH v3 05/20] media: imx355: Programmatically set the crop parameters for each mode Dave Stevenson
2026-07-08 14:48 ` [PATCH v3 06/20] media: imx355: Set register LINE_LENGTH_PCK programmatically Dave Stevenson
2026-07-08 14:48 ` [PATCH v3 07/20] media: imx355: Set binning mode registers programmatically Dave Stevenson
2026-07-08 14:48 ` [PATCH v3 08/20] media: imx355: Remove link_freq_index from each mode as ununsed Dave Stevenson
2026-07-08 14:48 ` [PATCH v3 09/20] media: imx355: pixel_rate never changes, so don't recompute Dave Stevenson
2026-07-08 15:01 ` sashiko-bot
2026-07-08 14:48 ` [PATCH v3 10/20] media: imx355: Remove redundant fll_min, and implement fixed offset Dave Stevenson
2026-07-08 15:05 ` sashiko-bot
2026-07-08 14:48 ` [PATCH v3 11/20] media: imx355: Add support for get_selection Dave Stevenson
2026-07-08 15:11 ` sashiko-bot
2026-07-08 14:48 ` [PATCH v3 12/20] media: imx355: Use pm_runtime autosuspend_delay Dave Stevenson
2026-07-08 15:06 ` sashiko-bot
2026-07-08 14:48 ` [PATCH v3 13/20] media: imx355: Convert to new CCI register access helpers Dave Stevenson
2026-07-08 15:08 ` sashiko-bot
2026-07-08 14:48 ` [PATCH v3 14/20] media: imx355: Set the colorspace in the format Dave Stevenson
2026-07-08 15:01 ` sashiko-bot
2026-07-08 14:48 ` [PATCH v3 15/20] media: imx355: Define the exposure offset, and use that define Dave Stevenson
2026-07-08 15:07 ` sashiko-bot [this message]
2026-07-08 14:48 ` [PATCH v3 16/20] media: imx355: Use NULL ctrl_ops for HBLANK as it is a read-only control Dave Stevenson
2026-07-08 14:48 ` [PATCH v3 17/20] media: imx355: Compute link frequency from PLL setup Dave Stevenson
2026-07-08 14:48 ` [PATCH v3 18/20] media: imx355: Support 2 lane readout Dave Stevenson
2026-07-08 14:48 ` [PATCH v3 19/20] media: imx355: Switch to using the subdev state Dave Stevenson
2026-07-08 15:10 ` sashiko-bot
2026-07-08 14:48 ` [PATCH v3 20/20] media: imx355: Remove storing cur_mode in the state Dave Stevenson
2026-07-08 15:17 ` sashiko-bot
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=20260708150721.4BEE01F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=dave.stevenson@raspberrypi.com \
--cc=devicetree@vger.kernel.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