From: Jihed Chaibi <jihed.chaibi.dev@gmail.com>
To: linux-sound@vger.kernel.org
Cc: lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz,
tiwai@suse.com, linux-kernel@vger.kernel.org,
jihed.chaibi.dev@gmail.com
Subject: [PATCH] ASoC: kirkwood: Fix clock error handling in probe
Date: Tue, 24 Mar 2026 21:55:51 +0100 [thread overview]
Message-ID: <20260324205551.38786-1-jihed.chaibi.dev@gmail.com> (raw)
Two problems in the same clock setup block:
1. clk_prepare_enable(priv->extclk) had its return value discarded,
while the immediately following clk_prepare_enable(priv->clk) was
correctly checked. A failure to enable the external clock was
silently ignored.
2. If clk_prepare_enable(priv->clk) failed, priv->extclk was already
enabled but never disabled — the error path returned directly
without cleanup.
Fix both by checking extclk enable and restructuring the error labels
to chain: err_component disables priv->clk then falls through to
err_extclk which disables priv->extclk if present.
Signed-off-by: Jihed Chaibi <jihed.chaibi.dev@gmail.com>
---
sound/soc/kirkwood/kirkwood-i2s.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/sound/soc/kirkwood/kirkwood-i2s.c b/sound/soc/kirkwood/kirkwood-i2s.c
index 99bd066c7309..ea734bc33dc3 100644
--- a/sound/soc/kirkwood/kirkwood-i2s.c
+++ b/sound/soc/kirkwood/kirkwood-i2s.c
@@ -695,14 +695,16 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev)
priv->extclk = ERR_PTR(-EINVAL);
} else {
dev_info(&pdev->dev, "found external clock\n");
- clk_prepare_enable(priv->extclk);
+ err = clk_prepare_enable(priv->extclk);
+ if (err < 0)
+ return err;
soc_dai = kirkwood_i2s_dai_extclk;
}
}
err = clk_prepare_enable(priv->clk);
if (err < 0)
- return err;
+ goto err_extclk;
/* Some sensible defaults - this reflects the powerup values */
priv->ctl_play = KIRKWOOD_PLAYCTL_SIZE_24;
@@ -729,9 +731,10 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev)
return 0;
err_component:
+ clk_disable_unprepare(priv->clk);
+ err_extclk:
if (!IS_ERR(priv->extclk))
clk_disable_unprepare(priv->extclk);
- clk_disable_unprepare(priv->clk);
return err;
}
--
2.47.3
next reply other threads:[~2026-03-24 20:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-24 20:55 Jihed Chaibi [this message]
2026-03-26 9:56 ` [PATCH] ASoC: kirkwood: Fix clock error handling in probe Jihed Chaibi
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=20260324205551.38786-1-jihed.chaibi.dev@gmail.com \
--to=jihed.chaibi.dev@gmail.com \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.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