From: Paolo Abeni <pabeni@redhat.com>
To: Pavel Zhigulin <Pavel.Zhigulin@kaspersky.com>,
Andrew Lunn <andrew+netdev@lunn.ch>
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Maxime Chevallier <maxime.chevallier@bootlin.com>,
Inochi Amaoto <inochiama@gmail.com>,
Quentin Schulz <quentin.schulz@cherry.de>,
Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp>,
Rayagond Kokatanur <rayagond@vayavyalabs.com>,
Giuseppe CAVALLARO <peppe.cavallaro@st.com>,
netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org
Subject: Re: [PATCH net v2] net: stmmac: add clk_prepare_enable() error handling
Date: Tue, 18 Nov 2025 15:42:35 +0100 [thread overview]
Message-ID: <53b3ac97-830a-47fc-a83c-3d12dac2e21a@redhat.com> (raw)
In-Reply-To: <4a3a8ba2-2535-461d-a0a5-e29873f538a4@redhat.com>
On 11/18/25 3:30 PM, Paolo Abeni wrote:
> On 11/14/25 3:23 PM, Pavel Zhigulin wrote:
>> The driver previously ignored the return value of 'clk_prepare_enable()'
>> for both the CSR clock and the PCLK in 'stmmac_probe_config_dt()' function.
>>
>> Add 'clk_prepare_enable()' return value checks.
>>
>> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>>
>> Fixes: bfab27a146ed ("stmmac: add the experimental PCI support")
>> Signed-off-by: Pavel Zhigulin <Pavel.Zhigulin@kaspersky.com>
>> ---
>> v2: Fix 'ret' value initialization after build bot notification.
>> v1: https://lore.kernel.org/all/20251113134009.79440-1-Pavel.Zhigulin@kaspersky.com/
>>
>> drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 11 +++++++++--
>> 1 file changed, 9 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
>> index 27bcaae07a7f..8f9eb9683d2b 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
>> @@ -632,7 +632,9 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac)
>> dev_warn(&pdev->dev, "Cannot get CSR clock\n");
>> plat->stmmac_clk = NULL;
>> }
>> - clk_prepare_enable(plat->stmmac_clk);
>> + rc = clk_prepare_enable(plat->stmmac_clk);
>> + if (rc < 0)
>> + dev_warn(&pdev->dev, "Cannot enable CSR clock: %d\n", rc);
>> }
>>
>> plat->pclk = devm_clk_get_optional(&pdev->dev, "pclk");
>> @@ -640,7 +642,12 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac)
>> ret = plat->pclk;
>> goto error_pclk_get;
>> }
>> - clk_prepare_enable(plat->pclk);
>> + rc = clk_prepare_enable(plat->pclk);
>> + if (rc < 0) {
>> + ret = ERR_PTR(rc);
>> + dev_err(&pdev->dev, "Cannot enable pclk: %d\n", rc);
>> + goto error_pclk_get;
>> + }
>
> It looks like the driver is supposed to handle the
> IS_ERR_OR_NULL(plat->pclk) condition. This check could cause regression
> on existing setup currently failing to initialize the (optional) clock
> and still being functional.
I'm sorry, ENOCOFFEE above, ->pclk is not NULL nor ERR when
clk_prepare_enable() fails. Still I don't stmmac code depending pclk
being successfully initialized, and the eventual regression looks like a
real possibility.
/P
next prev parent reply other threads:[~2025-11-18 14:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-14 14:23 [PATCH net v2] net: stmmac: add clk_prepare_enable() error handling Pavel Zhigulin
2025-11-18 14:30 ` Paolo Abeni
2025-11-18 14:42 ` Paolo Abeni [this message]
2025-11-18 17:14 ` Russell King (Oracle)
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=53b3ac97-830a-47fc-a83c-3d12dac2e21a@redhat.com \
--to=pabeni@redhat.com \
--cc=Pavel.Zhigulin@kaspersky.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=inochiama@gmail.com \
--cc=joe@pf.is.s.u-tokyo.ac.jp \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=lvc-project@linuxtesting.org \
--cc=maxime.chevallier@bootlin.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=peppe.cavallaro@st.com \
--cc=quentin.schulz@cherry.de \
--cc=rayagond@vayavyalabs.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;
as well as URLs for NNTP newsgroup(s).