ASoC: kirkwood: Fix clock error handling in probe
PATCH 1/1 ASoC: kirkwood: Fix clock error handling in probe
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.
--- sound/soc/kirkwood/kirkwood-i2s.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
sound/soc/kirkwood/kirkwood-i2s.c +6 -3
@@ -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; }
Signature · 1 line
2.47.3
Quoted 57 lines · Jihed Chaibi
Two problems in the same clock setup block:
1.
clk_prepare_enable(priv->extclk)had its return value discarded, while the immediately followingclk_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->extclkwas 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_componentdisablespriv->clkthen falls through toerr_extclkwhich disablespriv->extclkif present.Signed-off-by Jihed Chaibi <[email protected]>--- sound/soc/kirkwood/kirkwood-i2s.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)sound/soc/kirkwood/kirkwood-i2s.c +6
-4@@ -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; } --
Quoted 2 lines
2.47.3
Adding the missing Fixes tag:
play/record control registers")