From: sashiko-bot@kernel.org
To: "Ryan Chen" <ryan_chen@aspeedtech.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v33 2/5] i2c: aspeed: Read clock-frequency via i2c_parse_fw_timings()
Date: Tue, 23 Jun 2026 01:25:50 +0000 [thread overview]
Message-ID: <20260623012551.4569C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260623-upstream_i2c-v33-2-6d5338fc56ed@aspeedtech.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Pre-existing division by zero vulnerability if `bus-frequency` is set to 0 in the device tree.
--
commit 5605a3233169152a9f01c947946a36d0f4f9add6
Author: Ryan Chen <ryan_chen@aspeedtech.com>
i2c: aspeed: Read clock-frequency via i2c_parse_fw_timings()
This commit changes the driver to use i2c_parse_fw_timings() to read the
standard "clock-frequency" property. It falls back to "bus-frequency" only
when the standard property is absent.
> diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c
> index a26b74c712061..f00bd779146e7 100644
> --- a/drivers/i2c/busses/i2c-aspeed.c
> +++ b/drivers/i2c/busses/i2c-aspeed.c
[ ... ]
> @@ -1025,12 +1026,18 @@ static int aspeed_i2c_probe_bus(struct platform_device *pdev)
> }
> reset_control_deassert(bus->rst);
>
> - ret = of_property_read_u32(pdev->dev.of_node,
> - "bus-frequency", &bus->bus_frequency);
> - if (ret < 0) {
> - dev_err(&pdev->dev,
> - "Could not read bus-frequency property\n");
> - bus->bus_frequency = I2C_MAX_STANDARD_MODE_FREQ;
> + i2c_parse_fw_timings(&pdev->dev, &timings, false);
> + if (timings.bus_freq_hz) {
> + bus->bus_frequency = timings.bus_freq_hz;
> + } else {
> + ret = of_property_read_u32(pdev->dev.of_node,
> + "bus-frequency",
> + &bus->bus_frequency);
[Severity: High]
This is a pre-existing issue, but if "clock-frequency" is absent and
"bus-frequency" is explicitly set to 0 in the device tree,
bus->bus_frequency will be set to 0 here.
This can happen if 0 is used as a placeholder in the device tree for the
bootloader to fill in, but the bootloader fails to do so.
Does this lead to a division by zero panic later during initialization?
Looking at aspeed_i2c_init_clk() in drivers/i2c/busses/i2c-aspeed.c where
bus->bus_frequency is used:
divisor = DIV_ROUND_UP(bus->parent_clk_frequency, bus->bus_frequency);
Would it make sense to validate that bus->bus_frequency is non-zero after
reading it?
> + if (ret < 0) {
> + dev_err(&pdev->dev,
> + "Could not read clock-frequency or bus-frequency property\n");
> + bus->bus_frequency = I2C_MAX_STANDARD_MODE_FREQ;
> + }
> }
>
> match = of_match_node(aspeed_i2c_bus_of_table, pdev->dev.of_node);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260623-upstream_i2c-v33-0-6d5338fc56ed@aspeedtech.com?part=2
next prev parent reply other threads:[~2026-06-23 1:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-23 1:15 [PATCH v33 0/5] Add ASPEED AST2600 I2C controller driver Ryan Chen
2026-06-23 1:15 ` [PATCH v33 1/5] dt-bindings: i2c: Split AST2600 binding into a new YAML Ryan Chen
2026-06-23 1:15 ` [PATCH v33 2/5] i2c: aspeed: Read clock-frequency via i2c_parse_fw_timings() Ryan Chen
2026-06-23 1:25 ` sashiko-bot [this message]
2026-06-23 1:15 ` [PATCH v33 3/5] dt-bindings: i2c: ast2600-i2c.yaml: Add global-regs properties Ryan Chen
2026-06-23 1:15 ` [PATCH v33 4/5] i2c: ast2600: Add controller driver for AST2600 new register set Ryan Chen
2026-06-23 1:28 ` sashiko-bot
2026-06-23 3:01 ` Ryan Chen
2026-06-23 1:15 ` [PATCH v33 5/5] i2c: ast2600: Add target mode support Ryan Chen
2026-06-23 1:28 ` sashiko-bot
2026-06-23 2:55 ` Ryan Chen
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=20260623012551.4569C1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@kernel.org \
--cc=ryan_chen@aspeedtech.com \
--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.