[PATCH] ASoC: pcm512x: fix SCLK/supplies leak on resume failure

From: Tang Bin

Date: Wed Nov 04 2026 - 03:20:38 EST


pcm512x_resume() enabled SCLK then supplies, but each later failing step
(regcache_sync, regmap_update_bits) returned directly without undoing the
already-enabled resources, and the matching suspend() is not called by the
PM core on a failed resume. Use goto cleanup labels that disable supplies
and SCLK in reverse order.

Fixes: 5a3af1293194 ("ASoC: pcm512x: Add PCM512x driver")
Signed-off-by: Tang Bin <tangbin@xxxxxxxxxxxxxxxxxxxx>
---
sound/soc/codecs/pcm512x.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/sound/soc/codecs/pcm512x.c b/sound/soc/codecs/pcm512x.c
index f3e209190..24194a8ec 100644
--- a/sound/soc/codecs/pcm512x.c
+++ b/sound/soc/codecs/pcm512x.c
@@ -1772,24 +1772,31 @@ static int pcm512x_resume(struct device *dev)
pcm512x->supplies);
if (ret != 0) {
dev_err(dev, "Failed to enable supplies: %d\n", ret);
- return ret;
+ goto err_sclk;
}

regcache_cache_only(pcm512x->regmap, false);
ret = regcache_sync(pcm512x->regmap);
if (ret != 0) {
dev_err(dev, "Failed to sync cache: %d\n", ret);
- return ret;
+ goto err_supplies;
}

ret = regmap_update_bits(pcm512x->regmap, PCM512x_POWER,
PCM512x_RQPD, 0);
if (ret != 0) {
dev_err(dev, "Failed to remove power down: %d\n", ret);
- return ret;
+ goto err_supplies;
}

return 0;
+
+err_supplies:
+ regulator_bulk_disable(ARRAY_SIZE(pcm512x->supplies), pcm512x->supplies);
+err_sclk:
+ if (!IS_ERR(pcm512x->sclk))
+ clk_disable_unprepare(pcm512x->sclk);
+ return ret;
}

EXPORT_GPL_DEV_PM_OPS(pcm512x_pm_ops) = {
--
2.52.0.windows.1