From: sashiko-bot@kernel.org
To: "Pengyu Luo" <mitltlatltl@gmail.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, Frank.Li@kernel.org,
imx@lists.linux.dev, media-ci@linuxtv.org, conor+dt@kernel.org
Subject: Re: [PATCH v6 1/5] media: hi846: Fix hi846_write_reg_16 handling
Date: Sun, 30 Aug 2026 16:12:55 +0000 [thread overview]
Message-ID: <20260830161255.7E6181F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260830160025.211384-2-mitltlatltl@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Unbalanced pm_runtime_put() underflow and skipped I2C hardware writes result from unhandled negative error codes (e.g., -EINVAL) returned by pm_runtime_get_if_in_use().
--
commit baf92f1dfb7e9ab68d0b8a703aedfddfef46030d
Author: Pengyu Luo <mitltlatltl@gmail.com>
media: hi846: Fix hi846_write_reg_16 handling
hi846_write_reg_16() does not clear a positive *err value on success.
pm_runtime_get_if_in_use() returns a positive value when the device
is already in use. Fix this by resetting *err to 0 only when it is positive.
> diff --git a/drivers/media/i2c/hi846.c b/drivers/media/i2c/hi846.c
> index a3f77b8434ca7..7f069aca0fce5 100644
> --- a/drivers/media/i2c/hi846.c
> +++ b/drivers/media/i2c/hi846.c
> @@ -1271,6 +1271,8 @@ static void hi846_write_reg_16(struct hi846 *hi846, u16 reg, u16 val, int *err)
> if (*err < 0)
> return;
>
> + *err = 0;
> +
> put_unaligned_be16(reg, buf);
> put_unaligned_be16(val, buf + 2);
> ret = i2c_master_send(client, buf, sizeof(buf));
[Severity: High]
This is a pre-existing issue, but does the error handling in hi846_set_ctrl()
correctly handle negative error codes returned by pm_runtime_get_if_in_use()?
If pm_runtime_get_if_in_use() returns a negative error code (like -EINVAL),
it bypasses the early return condition:
drivers/media/i2c/hi846.c:hi846_set_ctrl() {
...
ret = pm_runtime_get_if_in_use(&client->dev);
if (!ret || ret == -EAGAIN)
return 0;
switch (ctrl->id) {
...
}
This causes the negative error code to propagate into the switch statement.
If the V4L2_CID_EXPOSURE or V4L2_CID_VBLANK case is hit, the negative value
is passed to hi846_write_reg_16(), which will immediately abort and skip all
I2C register initialization because of the `if (*err < 0)` check.
Furthermore, execution then unconditionally falls through to the end of
hi846_set_ctrl():
...
pm_runtime_put(&client->dev);
return ret;
}
Since a negative return from pm_runtime_get_if_in_use() means the reference
counter was not incremented, could this unconditional pm_runtime_put()
underflow the power management reference counter?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260830160025.211384-1-mitltlatltl@gmail.com?part=1
next prev parent reply other threads:[~2026-08-30 16:12 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-30 16:00 [PATCH v6 0/5] fix and improve for Hi846 Pengyu Luo
2026-08-30 16:00 ` [PATCH v6 1/5] media: hi846: Fix hi846_write_reg_16 handling Pengyu Luo
2026-08-30 16:12 ` sashiko-bot [this message]
2026-08-30 16:00 ` [PATCH v6 2/5] media: hi846: Fix link frequency handling Pengyu Luo
2026-08-30 16:17 ` sashiko-bot
2026-09-02 9:24 ` Sakari Ailus
2026-08-30 16:00 ` [PATCH v6 3/5] media: hi846: Fix modes handling for different lane cases Pengyu Luo
2026-08-30 16:16 ` sashiko-bot
2026-08-30 16:00 ` [PATCH v6 4/5] media: hi846: Add 6MP and 8MP modes support Pengyu Luo
2026-08-30 16:18 ` sashiko-bot
2026-08-30 16:00 ` [PATCH v6 5/5] arm64: dts: imx8mq-librem5: Correct link frequency list Pengyu Luo
2026-08-30 16:10 ` 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=20260830161255.7E6181F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=imx@lists.linux.dev \
--cc=media-ci@linuxtv.org \
--cc=mitltlatltl@gmail.com \
--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