From: sashiko-bot@kernel.org
To: "Dumitru Ceclan" <dumitru.ceclan@analog.com>
Cc: devicetree@vger.kernel.org, conor+dt@kernel.org,
media-ci@linuxtv.org, robh@kernel.org
Subject: Re: [PATCH v18 23/23] media: i2c: maxim-serdes: add MAX9296A driver
Date: Tue, 29 Sep 2026 23:00:34 +0000 [thread overview]
Message-ID: <20260929230034.ED61C1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260930-gmsl2-3_serdes-v18-23-43117818f499@analog.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] media: max9296a: undefined behavior from bit shift underflow when data-lane is 0
--
commit 6e4f4e297665312f959a24abeb56d6ec1fb1275e
Author: Cosmin Tanislav <demonsingur@gmail.com>
media: i2c: maxim-serdes: add MAX9296A driver
Add a new MAX9296A driver that also supports MAX96714, MAX96714F,
MAX96714R, MAX96716A and MAX96792A.
> diff --git a/drivers/media/i2c/maxim-serdes/max9296a.c b/drivers/media/i2c/maxim-serdes/max9296a.c
> new file mode 100644
> index 0000000000000..7b25b54e63deb
> --- /dev/null
> +++ b/drivers/media/i2c/maxim-serdes/max9296a.c
> @@ -0,0 +1,1461 @@
[ ... ]
> +static int max9296a_init_phy(struct max_des *des, struct max_des_phy *phy)
> +{
[ ... ]
> + for (i = 0; i < num_hw_data_lanes ; i++) {
> + unsigned int map;
> +
> + if (i < num_data_lanes)
> + map = phy->mipi.data_lanes[i] - 1;
> + else
> + map = ffz(used_data_lanes);
> +
> + val |= map << (i * 2);
> + used_data_lanes |= BIT(map);
> + }
[Severity: Medium]
If the device tree configures a data lane with index 0, could this underflow?
The V4L2 core parses the data-lanes property from the device tree, which can
contain a 0 index depending on the DT configuration. The driver's endpoint
parsing helper max_des_parse_src_dt_endpoint() verifies that lane indices are
<= num_data_lanes, but doesn't appear to explicitly check if the index is 0.
Since map is unsigned, phy->mipi.data_lanes[i] - 1 would underflow to
UINT_MAX when the index is 0. This could result in unpredictable state
corruption or a kernel panic via UBSAN when performing the bitwise shifts.
[ ... ]
> + for (i = 0, val = 0; i < num_data_lanes; i++) {
> + unsigned int map;
> +
> + if (!phy->mipi.lane_polarities[i + 1])
> + continue;
> +
> + /*
> + * The numbers inside the data_lanes array specify the hardware
> + * lane each logical lane maps to.
> + * If polarity is set for the physical lanes, retrieve the
> + * physical lane matching the logical lane from data_lanes.
> + * Otherwise, when polarity is set for the logical lanes
> + * the index of the polarity can be used.
> + */
> +
> + if (priv->info->polarity_on_physical_lanes)
> + map = phy->mipi.data_lanes[i] - 1;
> + else
> + map = i;
> +
> + val |= BIT(map);
> + }
[Severity: Medium]
Similarly, does this code also trigger an invalid shift when evaluating
polarities if the data-lane index is 0?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260930-gmsl2-3_serdes-v18-0-43117818f499@analog.com?part=23
next prev parent reply other threads:[~2026-09-29 23:00 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 22:41 [PATCH v18 00/23] media: i2c: add Maxim GMSL2/3 serializer and deserializer drivers Dumitru Ceclan via B4 Relay
2026-09-29 22:41 ` [PATCH v18 01/23] media: mc: Add INTERNAL pad flag Dumitru Ceclan via B4 Relay
2026-09-29 22:41 ` [PATCH v18 02/23] dt-bindings: media: i2c: max96717: add support for I2C ATR Dumitru Ceclan via B4 Relay
2026-09-29 22:52 ` sashiko-bot
2026-09-29 22:41 ` [PATCH v18 03/23] dt-bindings: media: i2c: max96717: add support for pinctrl/pinconf Dumitru Ceclan via B4 Relay
2026-10-06 15:06 ` Krzysztof Kozlowski
2026-09-29 22:41 ` [PATCH v18 04/23] dt-bindings: media: i2c: max96717: add support for MAX9295A Dumitru Ceclan via B4 Relay
2026-09-29 22:41 ` [PATCH v18 05/23] dt-bindings: media: i2c: max96717: add support for MAX96793 Dumitru Ceclan via B4 Relay
2026-09-29 22:41 ` [PATCH v18 06/23] dt-bindings: media: i2c: max96712: use pattern properties for ports Dumitru Ceclan via B4 Relay
2026-09-29 22:41 ` [PATCH v18 07/23] dt-bindings: media: i2c: max96712: add support for I2C ATR Dumitru Ceclan via B4 Relay
2026-09-29 22:41 ` [PATCH v18 08/23] dt-bindings: media: i2c: max96712: add support for POC supplies Dumitru Ceclan via B4 Relay
2026-09-29 22:41 ` [PATCH v18 09/23] dt-bindings: media: i2c: max96712: add support for MAX96724F/R Dumitru Ceclan via B4 Relay
2026-09-29 22:41 ` [PATCH v18 10/23] dt-bindings: media: i2c: max96712: add control-channel-port property Dumitru Ceclan via B4 Relay
2026-09-29 22:41 ` [PATCH v18 11/23] dt-bindings: media: i2c: max96714: add support for MAX96714R Dumitru Ceclan via B4 Relay
2026-10-06 15:07 ` Krzysztof Kozlowski
2026-09-29 22:41 ` [PATCH v18 12/23] dt-bindings: media: i2c: add MAX9296A, MAX96716A, MAX96792A Dumitru Ceclan via B4 Relay
2026-09-29 22:51 ` sashiko-bot
2026-09-29 22:41 ` [PATCH v18 13/23] i2c: atr: serialize attach/detach against bus transfers Dumitru Ceclan via B4 Relay
2026-09-29 22:41 ` [PATCH v18 14/23] media: i2c: add Maxim GMSL2/3 serializer and deserializer framework Dumitru Ceclan via B4 Relay
2026-09-29 22:41 ` [PATCH v18 15/23] media: i2c: add Maxim GMSL2/3 serializer framework Dumitru Ceclan via B4 Relay
2026-09-29 22:59 ` sashiko-bot
2026-09-29 22:41 ` [PATCH v18 16/23] media: i2c: add Maxim GMSL2/3 deserializer framework Dumitru Ceclan via B4 Relay
2026-09-29 22:58 ` sashiko-bot
2026-09-29 22:41 ` [PATCH v18 17/23] media: i2c: remove MAX96717 driver Dumitru Ceclan via B4 Relay
2026-09-29 22:41 ` [PATCH v18 18/23] media: i2c: maxim-serdes: add " Dumitru Ceclan via B4 Relay
2026-09-29 23:01 ` sashiko-bot
2026-09-29 22:41 ` [PATCH v18 19/23] arm64: defconfig: disable deprecated MAX96712 driver Dumitru Ceclan via B4 Relay
2026-09-29 22:51 ` sashiko-bot
2026-09-29 22:41 ` [PATCH v18 20/23] staging: media: remove " Dumitru Ceclan via B4 Relay
2026-09-29 22:41 ` [PATCH v18 21/23] media: i2c: maxim-serdes: add MAX96724 driver Dumitru Ceclan via B4 Relay
2026-09-29 22:41 ` [PATCH v18 22/23] media: i2c: remove MAX96714 driver Dumitru Ceclan via B4 Relay
2026-09-29 22:56 ` sashiko-bot
2026-09-29 22:41 ` [PATCH v18 23/23] media: i2c: maxim-serdes: add MAX9296A driver Dumitru Ceclan via B4 Relay
2026-09-29 23:00 ` sashiko-bot [this message]
2026-09-30 9:55 ` [PATCH v18 00/23] media: i2c: add Maxim GMSL2/3 serializer and deserializer drivers Sakari Ailus
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=20260929230034.ED61C1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dumitru.ceclan@analog.com \
--cc=media-ci@linuxtv.org \
--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