From: sashiko-bot@kernel.org
To: "Coia Prant" <coiaprant@gmail.com>
Cc: neil.armstrong@linaro.org, conor+dt@kernel.org, robh@kernel.org,
vkoul@kernel.org, wsa+renesas@sang-engineering.com,
devicetree@vger.kernel.org, olteanv@gmail.com,
linux-phy@lists.infradead.org
Subject: Re: [PATCH net-next v6 07/11] net: pcs: xpcs: add Rockchip RK3568 platform glue driver
Date: Wed, 16 Sep 2026 14:50:17 +0000 [thread overview]
Message-ID: <20260916145017.E901A1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260915123802.1561724-8-coiaprant@gmail.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] net: pcs: UAF in xpcs_rk_create due to lockless drvdata access
- [Low] kconfig: unmet PM_GENERIC_DOMAINS dependency via select
- [Low] net: pcs: integer underflow in EEE multiplier calculation
--
commit 45fa9f088b9d4ae656f2c67e864a462b4d229815
Author: Coia Prant <coiaprant@gmail.com>
net: pcs: xpcs: add Rockchip RK3568 platform glue driver
This commit adds a Rockchip RK3568 platform glue driver for the Synopsys
DesignWare XPCS controller. It creates a virtual MDIO bus to translate MDIO
operations to APB3 register accesses and derives the EEE multiplier at runtime.
Link: https://dl.radxa.com/rock3/docs/hw/datasheet/Rockchip%20RK3568%20TRM%20Part1%20V1.1-20210301.pdf
Link: https://dl.radxa.com/rock3/docs/hw/datasheet/Rockchip%20RK3568%20TRM%20Part2%20V1.1-20210301.pdf
> diff --git a/drivers/net/pcs/Kconfig b/drivers/net/pcs/Kconfig
> --- a/drivers/net/pcs/Kconfig
> +++ b/drivers/net/pcs/Kconfig
[ ... ]
> +config PCS_XPCS_ROCKCHIP
> + tristate "Rockchip XPCS controller support"
> + default ARCH_ROCKCHIP
> + depends on OF && (ARCH_ROCKCHIP || COMPILE_TEST)
> + select GENERIC_PHY
> + select PM_GENERIC_DOMAINS
[Severity: Low]
Will selecting PM_GENERIC_DOMAINS without inheriting its PM dependency cause
unmet direct dependency warnings?
The config PM_GENERIC_DOMAINS has a strict dependency on PM. If
PCS_XPCS_ROCKCHIP is enabled on a platform where PM is disabled, won't this
force PM_GENERIC_DOMAINS on and trigger Kconfig warnings?
> + help
> + Support for XPCS controller on Rockchip RK356x SoC.
[ ... ]
> diff --git a/drivers/net/pcs/pcs-xpcs-rk.c b/drivers/net/pcs/pcs-xpcs-rk.c
> --- /dev/null
> +++ b/drivers/net/pcs/pcs-xpcs-rk.c
[ ... ]
> +static int xpcs_rk_init_clk(struct dw_xpcs_rk *pxpcs)
> +{
[ ... ]
> + /*
> + * Compute the multiplier for the EEE clock so that
> + * clk_eee_period * (mult_fact + 1) falls within 80..120 ns.
> + *
> + * On RK3568, clk_xpcs_eee is muxed between gpll200 (200 MHz, 5 ns)
> + * and cpll125 (125 MHz, 8 ns), selected by CRU_CLKSEL_CON29 bit 13.
> + * The reset value is 0 (200 MHz), but derive the value at runtime to
> + * stay correct if the mux is changed by a board.
> + *
> + * Use a 64-bit intermediate: on 32-bit builds, 100 * 200000000
> + * does not fit in unsigned long. Clamp to the 4-bit
> + * DW_VR_MII_EEE_MULT_FACT_100NS field.
> + */
> + rate = clk_get_rate(pxpcs->eee_clk);
> + if (!rate)
> + return dev_err_probe(dev, -EINVAL, "Invalid EEE clock rate\n");
> +
> + mult = DIV_ROUND_CLOSEST_ULL(100ULL * rate, NSEC_PER_SEC) - 1;
> + pxpcs->eee_mult_fact = min_t(u64, mult, 15);
[Severity: Low]
Does this calculation underflow if the EEE clock rate is very low?
If the board configuration provides a clock rate under 5 MHz, the division
yields 0. Subtracting 1 causes an unsigned underflow to UINT64_MAX.
Won't the subsequent min_t() clamping logic evaluate UINT64_MAX < 15 as false,
incorrectly assigning the maximum multiplier of 15 instead of 0?
> + return 0;
> +}
[ ... ]
> +struct dw_xpcs *xpcs_rk_create(struct device *dev, struct device_node *np)
> +{
[ ... ]
> + if (!device_link_add(dev, &pdev->dev, DL_FLAG_AUTOREMOVE_CONSUMER)) {
> + put_device(&pdev->dev);
> + return ERR_PTR(-ENOMEM);
> + }
> +
> + pxpcs = platform_get_drvdata(pdev);
> + if (!pxpcs || !pxpcs->bus) {
[Severity: High]
Can this lockless access to the supplier's drvdata cause a use-after-free?
If the supplier driver is concurrently unbound via sysfs, the supplier might
have already passed the consumer unbind checks before this device link was
established.
If the supplier then proceeds to devres cleanup and frees the pxpcs memory,
won't dereferencing pxpcs->bus access freed memory?
Should the consumer hold device_lock(&pdev->dev) while validating the supplier
state and reading its drvdata to prevent this race?
> + device_link_remove(dev, &pdev->dev);
> + put_device(&pdev->dev);
> + return ERR_PTR(-EPROBE_DEFER);
> + }
> +
> + xpcs = xpcs_create_mdiodev(pxpcs->bus, (int)port);
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260915123802.1561724-1-coiaprant@gmail.com?part=7
next prev parent reply other threads:[~2026-09-16 14:50 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-15 12:37 [PATCH net-next v6 00/11] net: pcs: add basic support for RK3568 XPCS Coia Prant
2026-09-15 12:37 ` [PATCH net-next v6 01/11] net: stmmac: move XPCS lifetime management to platform drivers Coia Prant
2026-09-17 18:38 ` netdev-bot+sashiko
2026-09-17 20:00 ` Coia Prant
2026-09-15 12:37 ` [PATCH net-next v6 02/11] dt-bindings: phy: rockchip: naneng-combphy: add rockchip,sgmii-mac-sel property Coia Prant
2026-09-17 18:38 ` netdev-bot+sashiko
2026-09-15 12:37 ` [PATCH net-next v6 03/11] phy: rockchip: naneng-combphy: add SGMII MAC selection for RK3568 Coia Prant
2026-09-17 18:38 ` netdev-bot+sashiko
2026-09-17 20:02 ` Coia Prant
2026-09-15 12:37 ` [PATCH net-next v6 04/11] dt-bindings: net: pcs: add rockchip,rk3568-xpcs support Coia Prant
2026-09-17 18:38 ` netdev-bot+sashiko
2026-09-15 12:37 ` [PATCH net-next v6 05/11] arm64: dts: rockchip: rk3568: add XPCS and fixed-clock nodes Coia Prant
2026-09-16 14:50 ` sashiko-bot
2026-09-16 15:30 ` Coia Prant
2026-09-17 18:38 ` netdev-bot+sashiko
2026-09-17 20:15 ` Coia Prant
2026-09-15 12:37 ` [PATCH net-next v6 06/11] net: pcs: xpcs: add ANRESTART support for SGMII link recovery Coia Prant
2026-09-17 18:38 ` netdev-bot+sashiko
2026-09-15 12:37 ` [PATCH net-next v6 07/11] net: pcs: xpcs: add Rockchip RK3568 platform glue driver Coia Prant
2026-09-16 14:50 ` sashiko-bot [this message]
2026-09-16 15:54 ` Coia Prant
2026-09-17 18:38 ` netdev-bot+sashiko
2026-09-15 12:37 ` [PATCH net-next v6 08/11] dt-bindings: net: rockchip-dwmac: document pcs-handle Coia Prant
2026-09-17 18:38 ` netdev-bot+sashiko
2026-09-15 12:37 ` [PATCH net-next v6 09/11] net: stmmac: dwmac-rk: add SGMII support for RK3568 Coia Prant
2026-09-17 18:38 ` netdev-bot+sashiko
2026-09-15 12:37 ` [PATCH net-next v6 10/11] arm64: dts: rockchip: rk3568-photonicat: enable SGMII LAN port Coia Prant
2026-09-17 18:38 ` netdev-bot+sashiko
2026-09-15 12:38 ` [PATCH net-next v6 11/11] MAINTAINERS: add entry for Rockchip XPCS driver Coia Prant
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=20260916145017.E901A1F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=coiaprant@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=neil.armstrong@linaro.org \
--cc=olteanv@gmail.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vkoul@kernel.org \
--cc=wsa+renesas@sang-engineering.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox