From: Simon Horman <horms@kernel.org>
To: Yao Zi <ziyao@disroot.org>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
"Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>,
Jonas Karlman <jonas@kwiboo.se>,
David Wu <david.wu@rock-chips.com>,
Chaoyi Chen <chaoyi.chen@rock-chips.com>,
netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org
Subject: Re: [PATCH net] net: stmmac: dwmac-rk: Ensure clk_phy doesn't contain invalid address
Date: Thu, 4 Sep 2025 11:28:45 +0100 [thread overview]
Message-ID: <20250904102845.GG372207@horms.kernel.org> (raw)
In-Reply-To: <aLlleb271owHNIbt@pie>
On Thu, Sep 04, 2025 at 10:10:01AM +0000, Yao Zi wrote:
> On Thu, Sep 04, 2025 at 10:56:57AM +0100, Simon Horman wrote:
> > On Thu, Sep 04, 2025 at 10:54:57AM +0100, Simon Horman wrote:
> > > 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@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?
> >
> > Oops, I missed that da114122b831 is present in net-next (but not net).
> > Let me look over this a second time.
>
> Oops, yes. Though this is a fix patch, it should target net-next instead
> of net since the commit causing problems hasn't landed in net. Sorry for
> the confusion.
It's ok. I'm pretty good at confusing myself without any assistance.
WARNING: multiple messages have this Message-ID (diff)
From: Simon Horman <horms@kernel.org>
To: Yao Zi <ziyao@disroot.org>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
"Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>,
Jonas Karlman <jonas@kwiboo.se>,
David Wu <david.wu@rock-chips.com>,
Chaoyi Chen <chaoyi.chen@rock-chips.com>,
netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org
Subject: Re: [PATCH net] net: stmmac: dwmac-rk: Ensure clk_phy doesn't contain invalid address
Date: Thu, 4 Sep 2025 11:28:45 +0100 [thread overview]
Message-ID: <20250904102845.GG372207@horms.kernel.org> (raw)
In-Reply-To: <aLlleb271owHNIbt@pie>
On Thu, Sep 04, 2025 at 10:10:01AM +0000, Yao Zi wrote:
> On Thu, Sep 04, 2025 at 10:56:57AM +0100, Simon Horman wrote:
> > On Thu, Sep 04, 2025 at 10:54:57AM +0100, Simon Horman wrote:
> > > 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@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?
> >
> > Oops, I missed that da114122b831 is present in net-next (but not net).
> > Let me look over this a second time.
>
> Oops, yes. Though this is a fix patch, it should target net-next instead
> of net since the commit causing problems hasn't landed in net. Sorry for
> the confusion.
It's ok. I'm pretty good at confusing myself without any assistance.
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
next prev parent reply other threads:[~2025-09-04 11:27 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-04 3:12 [PATCH net] net: stmmac: dwmac-rk: Ensure clk_phy doesn't contain invalid address Yao Zi
2025-09-04 3:12 ` Yao Zi
2025-09-04 9:54 ` Simon Horman
2025-09-04 9:54 ` Simon Horman
2025-09-04 9:56 ` Simon Horman
2025-09-04 9:56 ` Simon Horman
2025-09-04 10:10 ` Yao Zi
2025-09-04 10:10 ` Yao Zi
2025-09-04 10:28 ` Simon Horman [this message]
2025-09-04 10:28 ` Simon Horman
2025-09-04 10:34 ` Simon Horman
2025-09-04 10:34 ` Simon Horman
2025-09-04 10:49 ` Russell King (Oracle)
2025-09-04 10:49 ` Russell King (Oracle)
2025-09-04 10:58 ` Chaoyi Chen
2025-09-04 10:58 ` Chaoyi Chen
2025-09-04 11:20 ` Yao Zi
2025-09-04 11:20 ` Yao Zi
2025-09-04 11:13 ` Yao Zi
2025-09-04 11:13 ` Yao Zi
2025-09-04 10:58 ` Russell King (Oracle)
2025-09-04 10:58 ` Russell King (Oracle)
2025-09-04 11:03 ` Chaoyi Chen
2025-09-04 11:03 ` Chaoyi Chen
2025-09-04 11:05 ` Russell King (Oracle)
2025-09-04 11:05 ` Russell King (Oracle)
2025-09-04 11:07 ` Russell King (Oracle)
2025-09-04 11:07 ` Russell King (Oracle)
2025-09-06 5:36 ` Yao Zi
2025-09-06 5:36 ` Yao Zi
2025-09-06 6:26 ` Chaoyi Chen
2025-09-06 6:26 ` Chaoyi Chen
2025-09-06 20:25 ` Sebastian Reichel
2025-09-06 20:25 ` Sebastian Reichel
2025-09-15 3:38 ` Chaoyi Chen
2025-09-15 3:38 ` Chaoyi 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=20250904102845.GG372207@horms.kernel.org \
--to=horms@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=chaoyi.chen@rock-chips.com \
--cc=davem@davemloft.net \
--cc=david.wu@rock-chips.com \
--cc=edumazet@google.com \
--cc=jonas@kwiboo.se \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rmk+kernel@armlinux.org.uk \
--cc=ziyao@disroot.org \
/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.