Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Wenmeng Liu" <wenmeng.liu@oss.qualcomm.com>
Cc: media-ci@linuxtv.org, robh@kernel.org,
	devicetree@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v5 3/4] media: i2c: og0ve1b: Introduce per-sensor data structure
Date: Fri, 31 Jul 2026 07:05:43 +0000	[thread overview]
Message-ID: <20260731070544.4F2EB1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260731-og0va1b-v5-3-c2b90b601241@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but incorrect handling of pm_runtime_get_if_active() error returns causes an unbalanced pm_runtime_put() and usage counter underflow.
--

--- Patch [3]: [PATCH v5 3/4] media: i2c: og0ve1b: Introduce per-sensor data structure ---
commit 4767769879b1fbb36a5857ed0679efc6bcd34ead
Author: Wenmeng Liu <wenmeng.liu@oss.qualcomm.com>

media: i2c: og0ve1b: Introduce per-sensor data structure

This refactors the driver to separate sensor-specific data from the common
driver code. It introduces a sensor_data structure populated through
i2c_get_match_data() to hold the chip ID, MCLK frequency, link frequencies,
and supported modes.

> diff --git a/drivers/media/i2c/og0ve1b.c b/drivers/media/i2c/og0ve1b.c
> index da5c8e49d4a81..f560d5d90fda9 100644
> --- a/drivers/media/i2c/og0ve1b.c
> +++ b/drivers/media/i2c/og0ve1b.c

[ ... ]

> @@ -314,7 +339,7 @@ static int og0ve1b_set_ctrl(struct v4l2_ctrl *ctrl)
>  				ctrl->val + mode->height, NULL);
>  		break;
>  	case V4L2_CID_TEST_PATTERN:
> -		ret = og0ve1b_enable_test_pattern(og0ve1b, ctrl->val);
> +		ret = og0ve1b->data->enable_test_pattern(og0ve1b, ctrl->val);
>  		break;
>  	default:
>  		ret = -EINVAL;

[Severity: High]
This isn't a bug introduced by this patch, but while reviewing
og0ve1b_set_ctrl(), I noticed a potential PM usage counter underflow.

Earlier in this function, there is a check:

	if (!pm_runtime_get_if_active(og0ve1b->dev))
		return 0;

If pm_runtime_get_if_active() returns a negative error code (like -EINVAL
when Runtime PM is disabled), the negation !(-EINVAL) evaluates to false.
This bypasses the early return.

Execution then proceeds through this switch statement and unconditionally
calls pm_runtime_put(og0ve1b->dev) at the end of the function. 

Since the initial get failed and never incremented the usage counter,
wouldn't this unconditional put operation cause an unbalanced decrement and
underflow the counter?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260731-og0va1b-v5-0-c2b90b601241@oss.qualcomm.com?part=3

  reply	other threads:[~2026-07-31  7:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-31  6:44 [PATCH v5 0/4] media: i2c: Add OmniVision OG0VA1B camera sensor driver Wenmeng Liu
2026-07-31  6:44 ` [PATCH v5 1/4] dt-bindings: media: i2c: og0ve1b: Add OmniVision OG0VA1B camera sensor Wenmeng Liu
2026-07-31  6:44 ` [PATCH v5 2/4] media: i2c: og0ve1b: Use monochrome-appropriate test pattern name Wenmeng Liu
2026-07-31  7:06   ` Vladimir Zapolskiy
2026-07-31  6:44 ` [PATCH v5 3/4] media: i2c: og0ve1b: Introduce per-sensor data structure Wenmeng Liu
2026-07-31  7:05   ` sashiko-bot [this message]
2026-07-31  6:44 ` [PATCH v5 4/4] media: i2c: og0ve1b: Add support for OmniVision OG0VA1B Wenmeng Liu

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=20260731070544.4F2EB1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=media-ci@linuxtv.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=wenmeng.liu@oss.qualcomm.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