From: sashiko-bot@kernel.org
To: "Pengyu Luo" <mitltlatltl@gmail.com>
Cc: conor+dt@kernel.org, Frank.Li@kernel.org,
devicetree@vger.kernel.org, robh@kernel.org, imx@lists.linux.dev
Subject: Re: [PATCH v5 1/5] media: hi846: Fix hi846_write_reg_16 handling
Date: Sun, 12 Jul 2026 12:09:24 +0000 [thread overview]
Message-ID: <20260712120924.C96DD1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260712115553.92564-1-mitltlatltl@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Improper error handling of `pm_runtime_get_if_in_use()` causes skipped I2C writes when Runtime PM is disabled (e.g., CONFIG_PM=n).
--
--- Patch [1]: [PATCH v5 1/5] media: hi846: Fix hi846_write_reg_16 handling ---
commit a93dfb63bfce92d91d72fc1b7b2f261ebe6609ab
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. When hi846_set_ctrl() passes &ret holding this
positive value) to hi846_write_reg_16(), the function returns with ret
as is, the positive value propagates back as a return code, which
callers interpret as an error.
Fix this by resetting *err to 0 only when it is positive.
Fixes: 04fc06f6dc15 ("media: hi846: fix usage of pm_runtime_get_if_in_use()")
> 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;
> +
[Severity: High]
This is a pre-existing issue, but does hi846_set_ctrl() properly handle
negative errors like -EINVAL from pm_runtime_get_if_in_use() when CONFIG_PM
is disabled?
When CONFIG_PM is disabled, pm_runtime_get_if_in_use() returns -EINVAL.
Because hi846_set_ctrl() checks if (!ret || ret == -EAGAIN), it will fall
through and pass the -EINVAL via &ret to hi846_write_reg_16():
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) {
...
case V4L2_CID_VBLANK:
/* Update FLL that meets expected vertical blanking */
hi846_write_reg_16(hi846, HI846_REG_FLL,
hi846->cur_mode->height + ctrl->val, &ret);
break;
...
}
Because hi846_write_reg_16() exits early on negative errors, won't this
skip all I2C register writes when CONFIG_PM is disabled?
> put_unaligned_be16(reg, buf);
> put_unaligned_be16(val, buf + 2);
> ret = i2c_master_send(client, buf, sizeof(buf));
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260712115012.91600-1-mitltlatltl@gmail.com?part=1
prev parent reply other threads:[~2026-07-12 12:09 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-12 11:50 [PATCH v5 0/5] fix and improve for Hi846 Pengyu Luo
2026-07-12 11:50 ` [PATCH v5 2/5] media: hi846: Fix link frequency handling Pengyu Luo
2026-07-12 12:10 ` sashiko-bot
2026-07-12 11:50 ` [PATCH v5 3/5] media: hi846: Fix modes handling for different lane cases Pengyu Luo
2026-07-12 12:07 ` sashiko-bot
2026-07-12 11:50 ` [PATCH v5 4/5] media: hi846: Add 6MP and 8MP modes support Pengyu Luo
2026-07-12 12:13 ` sashiko-bot
2026-07-12 11:50 ` [PATCH v5 5/5] arm64: dts: imx8mq-librem5: Correct link frequency list Pengyu Luo
2026-07-12 12:05 ` sashiko-bot
2026-07-12 11:55 ` [PATCH v5 1/5] media: hi846: Fix hi846_write_reg_16 handling Pengyu Luo
2026-07-12 12:09 ` sashiko-bot [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=20260712120924.C96DD1F000E9@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=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.