Netdev List
 help / color / mirror / Atom feed
From: "Gustavo Kenji Mendonça Kaneko" <kaneko.dev@pm.me>
To: netdev@vger.kernel.org
Cc: theo.lebrun@bootlin.com, conor.dooley@microchip.com,
	davem@davemloft.net, kuba@kernel.org,
	linux-kernel@vger.kernel.org,
	"Gustavo Kenji Mendonça Kaneko" <kaneko.dev@pm.me>
Subject: [PATCH] net: macb: fix ignored return value of clk_prepare_enable() in runtime resume
Date: Sun, 31 May 2026 05:18:55 +0000	[thread overview]
Message-ID: <20260531051841.55311-1-kaneko.dev@pm.me> (raw)

macb_runtime_resume() calls clk_prepare_enable() five times without
checking the return value. If any clock fails to enable, the driver
silently continues with potentially unclocked hardware, which can
cause undefined behavior or system instability on resume from runtime
suspend.

The existing macb_clks_disable() already uses clk_bulk_disable_unprepare()
for the symmetric disable path. Align the enable path by using
clk_bulk_prepare_enable(), which atomically enables all clocks and
automatically rolls back any successfully enabled clocks on failure.

Signed-off-by: Gustavo Kenji Mendonça Kaneko <kaneko.dev@pm.me>
---
 drivers/net/ethernet/cadence/macb_main.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index a12aa21244e8..85bd4ff0e4e6 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -6185,16 +6185,19 @@ static int __maybe_unused macb_runtime_resume(struct device *dev)
 {
 	struct net_device *netdev = dev_get_drvdata(dev);
 	struct macb *bp = netdev_priv(netdev);
+	struct clk_bulk_data clks[] = {
+		{ .clk = bp->pclk },
+		{ .clk = bp->hclk },
+		{ .clk = bp->tx_clk },
+		{ .clk = bp->rx_clk },
+		{ .clk = bp->tsu_clk },
+	};
 
-	if (!(device_may_wakeup(dev))) {
-		clk_prepare_enable(bp->pclk);
-		clk_prepare_enable(bp->hclk);
-		clk_prepare_enable(bp->tx_clk);
-		clk_prepare_enable(bp->rx_clk);
-		clk_prepare_enable(bp->tsu_clk);
-	} else if (!(bp->caps & MACB_CAPS_NEED_TSUCLK)) {
-		clk_prepare_enable(bp->tsu_clk);
-	}
+	if (!(device_may_wakeup(dev)))
+		return clk_bulk_prepare_enable(ARRAY_SIZE(clks), clks);
+
+	if (!(bp->caps & MACB_CAPS_NEED_TSUCLK))
+		return clk_prepare_enable(bp->tsu_clk);
 
 	return 0;
 }
-- 
2.54.0



             reply	other threads:[~2026-05-31  5:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-31  5:18 Gustavo Kenji Mendonça Kaneko [this message]
2026-05-31  6:41 ` [PATCH] net: macb: fix ignored return value of clk_prepare_enable() in runtime resume Théo Lebrun

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=20260531051841.55311-1-kaneko.dev@pm.me \
    --to=kaneko.dev@pm.me \
    --cc=conor.dooley@microchip.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=theo.lebrun@bootlin.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