From: Jiawen Liu <1298662399@qq.com>
To: Chen-Yu Tsai <wens@kernel.org>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Samuel Holland <samuel@sholland.org>,
dri-devel@lists.freedesktop.org,
linux-arm-kernel@lists.infradead.org,
linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [PATCH] drm/sun4i: frontend: fix clock leak on reset failure in runtime resume
Date: Tue, 18 Aug 2026 17:27:15 +0400 [thread overview]
Message-ID: <tencent_3AEE86932EE0F9AF7D6549FD705139A4AF06@qq.com> (raw)
sun4i_frontend_runtime_resume() can fail after enabling the bus, mod,
and ram clocks if reset_control_reset() returns an error. The function
previously returned without disabling those clocks, leaking them and
leaving the hardware in an inconsistent state.
Check the return value of each clk_prepare_enable() call and unwind the
clocks that were successfully enabled on any subsequent failure,
including reset failure.
Signed-off-by: jiawen <1298662399@qq.com>
---
diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.c b/drivers/gpu/drm/sun4i/sun4i_frontend.c
--- a/drivers/gpu/drm/sun4i/sun4i_frontend.c
+++ b/drivers/gpu/drm/sun4i/sun4i_frontend.c
@@ -647,14 +647,22 @@
clk_set_rate(frontend->mod_clk, 300000000);
- clk_prepare_enable(frontend->bus_clk);
- clk_prepare_enable(frontend->mod_clk);
- clk_prepare_enable(frontend->ram_clk);
+ ret = clk_prepare_enable(frontend->bus_clk);
+ if (ret)
+ return ret;
+
+ ret = clk_prepare_enable(frontend->mod_clk);
+ if (ret)
+ goto err_disable_bus_clk;
+
+ ret = clk_prepare_enable(frontend->ram_clk);
+ if (ret)
+ goto err_disable_mod_clk;
ret = reset_control_reset(frontend->reset);
if (ret) {
dev_err(dev, "Couldn't reset our device\n");
- return ret;
+ goto err_disable_ram_clk;
}
regmap_update_bits(frontend->regs, SUN4I_FRONTEND_EN_REG,
@@ -664,6 +672,14 @@
sun4i_frontend_scaler_init(frontend);
return 0;
+
+err_disable_ram_clk:
+ clk_disable_unprepare(frontend->ram_clk);
+err_disable_mod_clk:
+ clk_disable_unprepare(frontend->mod_clk);
+err_disable_bus_clk:
+ clk_disable_unprepare(frontend->bus_clk);
+ return ret;
}
static int sun4i_frontend_runtime_suspend(struct device *dev)
next reply other threads:[~2026-08-18 13:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-18 13:27 Jiawen Liu [this message]
2026-08-18 13:34 ` [PATCH] drm/sun4i: frontend: fix clock leak on reset failure in runtime resume sashiko-bot
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=tencent_3AEE86932EE0F9AF7D6549FD705139A4AF06@qq.com \
--to=1298662399@qq.com \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jernej.skrabec@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=samuel@sholland.org \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
--cc=wens@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox