From: sashiko-bot@kernel.org
To: "Pengyu Luo" <mitltlatltl@gmail.com>
Cc: devicetree@vger.kernel.org, conor+dt@kernel.org,
krzk+dt@kernel.org, Frank.Li@kernel.org, robh@kernel.org,
imx@lists.linux.dev
Subject: Re: [PATCH v3 3/5] media: hi846: fix modes handling for different lane cases
Date: Tue, 12 May 2026 02:35:16 +0000 [thread overview]
Message-ID: <20260512023517.45C7DC2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260511090924.269106-4-mitltlatltl@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] The mode filtering logic for 4-lane setups relies on brittle array pointer arithmetic and implicitly assumes a specific global array ordering.
- [Low] A local variable shadows a global variable in `hi846_enum_frame_size`.
--
commit 809f6817858f4d273d756eeec1b017198bbcfa3a
Author: Pengyu Luo <mitltlatltl@gmail.com>
media: hi846: fix modes handling for different lane cases
When using 4-lane, a 640x480 mode may be incorrectly set. This patch fixes
the issue by specifying the supported modes and mode count dynamically based
on the number of lanes.
Closes: https://lore.kernel.org/linux-media/OmTXoHZJTSGePymL9I-1Cw@puri.sm/
Fixes: e8c0882685f9 ("media: i2c: add driver for the SK Hynix Hi-846 8M pixel camera")
> diff --git a/drivers/media/i2c/hi846.c b/drivers/media/i2c/hi846.c
> index befd54553df2e..9decfda747876 100644
> --- a/drivers/media/i2c/hi846.c
> +++ b/drivers/media/i2c/hi846.c
[ ... ]
> @@ -1821,8 +1825,11 @@ static int hi846_enum_frame_size(struct v4l2_subdev *sd,
> struct v4l2_subdev_frame_size_enum *fse)
> {
> struct i2c_client *client = v4l2_get_subdevdata(sd);
> + struct hi846 *hi846 = to_hi846(sd);
> + const struct hi846_mode *supported_modes = hi846->supported_modes;
This isn't a bug, but does declaring supported_modes here shadow the global
static array supported_modes[] defined earlier in the file?
[ ... ]
> @@ -1999,6 +2006,13 @@ static int hi846_parse_dt(struct hi846 *hi846, struct device *dev)
>
> hi846->nr_lanes = bus_cfg.bus.mipi_csi2.num_data_lanes;
>
> + hi846->supported_modes = supported_modes;
> + hi846->num_modes = NUM_MODES_2LANE;
> + if (hi846->nr_lanes == 4) {
> + hi846->supported_modes = supported_modes + 1;
> + hi846->num_modes = NUM_MODES_4LANE;
> + }
Does this mode filtering logic rely on the exact ordering of the global
supported_modes array?
By advancing the array pointer by 1 and using a hardcoded mode count for the
4-lane setup, this implicitly assumes the only mode incompatible with 4-lane
operation is located exactly at the first index.
If another 2-lane-only mode is added or the modes are reordered in the future,
could this silently corrupt the subdevice's mode list by misaligning the array
bounds?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260511090924.269106-1-mitltlatltl@gmail.com?part=3
next prev parent reply other threads:[~2026-05-12 2:35 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
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 [this message]
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=20260512023517.45C7DC2BCB0@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 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.