[PATCH net] net: stmmac: dwmac-rk: Ensure clk_phy doesn't contain invalid address
Simon Horman
horms at kernel.org
Thu Sep 4 02:54:57 PDT 2025
On Thu, Sep 04, 2025 at 03:12:24AM +0000, Yao Zi wrote:
> We must set the clk_phy pointer to NULL to indicating it isn't available
> if the optional phy clock couldn't be obtained. Otherwise the error code
> returned by of_clk_get() could be wrongly taken as an address, causing
> invalid pointer dereference when later clk_phy is passed to
> clk_prepare_enable().
>
> Fixes: da114122b831 ("net: ethernet: stmmac: dwmac-rk: Make the clk_phy could be used for external phy")
> Signed-off-by: Yao Zi <ziyao at disroot.org>
...
Hi,
I this patch doesn't seem to match upstream code.
Looking over the upstream code, it seems to me that
going into the code in question .clk_phy should
be NULL, as bsp_priv it is allocated using devm_kzalloc()
over in rk_gmac_setup()
While the upstream version of the code your patch modifies
is as follows. And doesn't touch .clk_phy if integrated_phy is not set.
if (plat->phy_node && bsp_priv->integrated_phy) {
bsp_priv->clk_phy = of_clk_get(plat->phy_node, 0);
ret = PTR_ERR_OR_ZERO(bsp_priv->clk_phy);
if (ret)
return dev_err_probe(dev, ret, "Cannot get PHY clock\n");
clk_set_rate(bsp_priv->clk_phy, 50000000);
}
Am I missing something?
More information about the linux-arm-kernel
mailing list