From: sashiko-bot@kernel.org
To: "Pengyu Luo" <mitltlatltl@gmail.com>
Cc: imx@lists.linux.dev, robh@kernel.org, Frank.Li@kernel.org,
conor+dt@kernel.org, krzk+dt@kernel.org,
devicetree@vger.kernel.org
Subject: Re: [PATCH v3 1/5] media: hi846: fix hi846_write_reg_16 handling
Date: Tue, 12 May 2026 01:24:23 +0000 [thread overview]
Message-ID: <20260512012424.4A699C2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260511090924.269106-2-mitltlatltl@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Unhandled negative error code from pm_runtime_get_if_in_use() causes silent failure of exposure/vblank controls and PM usage count underflow.
--
commit 4a36c43ca7959e04a86201166380c7cb4acf35d4
Author: Pengyu Luo <mitltlatltl@gmail.com>
media: hi846: fix hi846_write_reg_16 handling
This commit fixes an issue where a positive return value from
pm_runtime_get_if_in_use() propagates back to callers as an error. It resets
the error pointer to 0 inside hi846_write_reg_16() before performing I2C
operations.
> 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;
While this patch handles the positive return code, does it miss the case
where pm_runtime_get_if_in_use() returns a negative error code like -EINVAL?
If runtime PM is disabled, pm_runtime_get_if_in_use() returns -EINVAL. In
hi846_set_ctrl(), the error check misses this negative value:
drivers/media/i2c/hi846.c:hi846_set_ctrl() {
...
ret = pm_runtime_get_if_in_use(&client->dev);
if (!ret || ret == -EAGAIN)
return 0;
...
}
This allows the negative ret to propagate to hi846_write_reg_16(). Since
*err is less than zero, the function returns immediately, silently skipping
all hardware writes for V4L2_CID_EXPOSURE and V4L2_CID_VBLANK.
Additionally, does this cause a PM usage count underflow?
At the end of hi846_set_ctrl(), pm_runtime_put() is called unconditionally:
drivers/media/i2c/hi846.c:hi846_set_ctrl() {
...
pm_runtime_put(&client->dev);
return ret;
}
Since the usage count was never incremented when pm_runtime_get_if_in_use()
returned -EINVAL, this might trigger a usage count underflow warning.
Could hi846_set_ctrl() explicitly isolate the PM status, set ret to 0 before
making hardware writes, and only call pm_runtime_put() if the get function
returned a value greater than 0?
> + *err = 0;
> +
> 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/20260511090924.269106-1-mitltlatltl@gmail.com?part=1
next prev parent reply other threads:[~2026-05-12 1:24 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-11 9:09 [PATCH v3 0/5] fix and improve for Hi846 Pengyu Luo
2026-05-11 9:09 ` [PATCH v3 1/5] media: hi846: fix hi846_write_reg_16 handling Pengyu Luo
2026-05-11 9:36 ` Markus Elfring
2026-05-12 1:24 ` sashiko-bot [this message]
2026-05-11 9:09 ` [PATCH v3 2/5] media: hi846: fix link frequency handling Pengyu Luo
2026-05-11 10:42 ` Markus Elfring
2026-05-12 1:56 ` sashiko-bot
2026-05-11 9:09 ` [PATCH v3 3/5] media: hi846: fix modes handling for different lane cases Pengyu Luo
2026-05-12 2:35 ` sashiko-bot
2026-05-11 9:09 ` [PATCH v3 4/5] media: hi846: Add 6MP and 8MP modes support Pengyu Luo
2026-05-12 3:22 ` sashiko-bot
2026-05-11 9:09 ` [PATCH v3 5/5] arm64: dts: imx8mq-librem5: Correct link frequency list Pengyu Luo
2026-05-12 3:48 ` 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=20260512012424.4A699C2BCB0@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=krzk+dt@kernel.org \
--cc=mitltlatltl@gmail.com \
--cc=robh@kernel.org \
--cc=sashiko@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