From: netdev-bot+sashiko@kernel.org
To: mkl@pengutronix.de
Cc: mailhol@kernel.org, socketcan@hartkopp.net, wg@grandegger.com,
davem@davemloft.net, kernel@pengutronix.de,
linux-can@vger.kernel.org, ssureshmsd7@gmail.com,
25031212351@stu.xidian.edu.cn, stable@vger.kernel.org,
byu@xidian.edu.cn, wencheng@xidian.edu.cn, kuba@kernel.org
Subject: Re: [PATCH can-next v2 1/4] can: bittiming: fix divide-by-zero in can_calc_bittiming()
Date: Wed, 02 Dec 2026 01:07:37 +0000 [thread overview]
Message-ID: <179617365740.3142.9703576724478254959@kernel.org> (raw)
In-Reply-To: <20261130-bittiming-fix-conversion-v2-1-36e8a0275923@pengutronix.de>
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message misstates where priv->bitrate_max comes from.
--
can: bittiming: fix divide-by-zero in can_calc_bittiming()
This commit fixes a divide error in can_calc_bittiming(). The divide
error happens when the 32 bit product tsegall * bt->bitrate wraps to
zero for large userspace bitrates. The fix computes the product with
mul_u32_u32() and divides with div64_u64().
> priv->bitrate_max cannot guard against this: it is populated from the
> optional "max-bitrate" device tree property, so it is zero for most
> drivers, and can_changelink() only consults it after can_get_bittiming()
> has already returned.
[Severity: Low]
Is this description of where priv->bitrate_max comes from accurate?
The "max-bitrate" device tree property is one source. Several drivers
also take it from the generic PHY transceiver:
drivers/net/can/flexcan/flexcan-core.c:flexcan_probe() {
...
priv->can.bitrate_max = transceiver->attrs.max_link_rate;
...
}
at91_can.c, m_can_platform.c and rcar_canfd.c do the same.
Some drivers also hard-code the value. etas_es58x sets 1 MBit/s for
es581_4 and 8 MBit/s for es58x_fd. dummy_can, the driver used for the
reproduction, sets:
drivers/net/can/dummy_can.c:dummy_can_init() {
...
priv->can.bitrate_max = 20 * MEGA /* BPS */;
...
}
So bitrate_max is non-zero on the reproduction driver. The second
argument in the paragraph still holds. can_changelink() calls
can_get_bittiming() before it checks the limit:
drivers/net/can/dev/netlink.c:can_changelink() {
...
err = can_get_bittiming(dev, &bt,
priv->bittiming_const,
...
if (priv->bitrate_max && bt.bitrate > priv->bitrate_max) {
...
}
The data bittiming path follows the same order.
The code change itself looks correct. Could the paragraph drop the "zero
for most drivers" reasoning and keep only the ordering argument?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130-bittiming-fix-conversion-v2-0-36e8a0275923%40pengutronix.de
next prev parent reply other threads:[~2026-12-02 1:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 11:13 [PATCH can-next v2 0/4] can: bittiming: fix defects in the userspace bit rate conversion and reject invalid timing constants Marc Kleine-Budde
2026-11-30 11:13 ` [PATCH can-next v2 1/4] can: bittiming: fix divide-by-zero in can_calc_bittiming() Marc Kleine-Budde
2026-12-02 1:07 ` netdev-bot+sashiko [this message]
2026-11-30 11:13 ` [PATCH can-next v2 2/4] can: bittiming: fix bitrate error calculation on unsigned operands Marc Kleine-Budde
2026-11-30 11:13 ` [PATCH can-next v2 3/4] can: bittiming: can_update_sample_point(): fix sample point " Marc Kleine-Budde
2026-12-02 1:07 ` netdev-bot+sashiko
2026-11-30 11:13 ` [PATCH can-next v2 4/4] can: dev: reject unusable bit-timing constants Marc Kleine-Budde
2026-11-30 11:25 ` sashiko-bot
2026-11-30 13:07 ` Marc Kleine-Budde
2026-12-02 1:07 ` netdev-bot+sashiko
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=179617365740.3142.9703576724478254959@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=25031212351@stu.xidian.edu.cn \
--cc=byu@xidian.edu.cn \
--cc=davem@davemloft.net \
--cc=kernel@pengutronix.de \
--cc=kuba@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=mailhol@kernel.org \
--cc=mkl@pengutronix.de \
--cc=socketcan@hartkopp.net \
--cc=ssureshmsd7@gmail.com \
--cc=stable@vger.kernel.org \
--cc=wencheng@xidian.edu.cn \
--cc=wg@grandegger.com \
/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.