public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Nuno Sá" <noname.nuno@gmail.com>
To: Jihed Chaibi <jihed.chaibi.dev@gmail.com>,
	lars@metafoo.de,  nuno.sa@analog.com
Cc: lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz,
	tiwai@suse.com, linux-sound@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] ASoC: adau1372: Fix unchecked clk_prepare_enable() return value
Date: Thu, 26 Mar 2026 09:27:32 +0000	[thread overview]
Message-ID: <67b84d7381662363a300fc108d8111d777489a50.camel@gmail.com> (raw)
In-Reply-To: <20260325210704.76847-2-jihed.chaibi.dev@gmail.com>

On Wed, 2026-03-25 at 22:07 +0100, Jihed Chaibi wrote:
> adau1372_set_power() calls clk_prepare_enable() but discards the return
> value. If the clock enable fails, the driver proceeds to access registers
> on unpowered hardware, potentially causing silent corruption.
> 
> Make adau1372_set_power() return int and propagate the error from
> clk_prepare_enable(). Update adau1372_set_bias_level() to return the
> error directly for the STANDBY and OFF cases.
> 
> Signed-off-by: Jihed Chaibi <jihed.chaibi.dev@gmail.com>
> ---

No Fixes tag?

- Nuno Sá

> Changes in v2:
> - No changes.
> 
>  sound/soc/codecs/adau1372.c | 17 ++++++++++-------
>  1 file changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/sound/soc/codecs/adau1372.c b/sound/soc/codecs/adau1372.c
> index fdee689cae53..6345342218d6 100644
> --- a/sound/soc/codecs/adau1372.c
> +++ b/sound/soc/codecs/adau1372.c
> @@ -782,15 +782,18 @@ static void adau1372_enable_pll(struct adau1372 *adau1372)
>  		dev_err(adau1372->dev, "Failed to lock PLL\n");
>  }
> 
> -static void adau1372_set_power(struct adau1372 *adau1372, bool enable)
> +static int adau1372_set_power(struct adau1372 *adau1372, bool enable)
>  {
>  	if (adau1372->enabled == enable)
> -		return;
> +		return 0;
> 
>  	if (enable) {
>  		unsigned int clk_ctrl = ADAU1372_CLK_CTRL_MCLK_EN;
> +		int ret;
> 
> -		clk_prepare_enable(adau1372->mclk);
> +		ret = clk_prepare_enable(adau1372->mclk);
> +		if (ret)
> +			return ret;
>  		if (adau1372->pd_gpio)
>  			gpiod_set_value(adau1372->pd_gpio, 0);
> 
> @@ -829,6 +832,8 @@ static void adau1372_set_power(struct adau1372 *adau1372, bool enable)
>  	}
> 
>  	adau1372->enabled = enable;
> +
> +	return 0;
>  }
> 
>  static int adau1372_set_bias_level(struct snd_soc_component *component,
> @@ -842,11 +847,9 @@ static int adau1372_set_bias_level(struct snd_soc_component *component,
>  	case SND_SOC_BIAS_PREPARE:
>  		break;
>  	case SND_SOC_BIAS_STANDBY:
> -		adau1372_set_power(adau1372, true);
> -		break;
> +		return adau1372_set_power(adau1372, true);
>  	case SND_SOC_BIAS_OFF:
> -		adau1372_set_power(adau1372, false);
> -		break;
> +		return adau1372_set_power(adau1372, false);
>  	}
> 
>  	return 0;
> --
> 2.47.3

  reply	other threads:[~2026-03-26  9:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-25 21:07 [PATCH v2 0/2] ASoC: adau1372: Fix error handling in adau1372_set_power() Jihed Chaibi
2026-03-25 21:07 ` [PATCH v2 1/2] ASoC: adau1372: Fix unchecked clk_prepare_enable() return value Jihed Chaibi
2026-03-26  9:27   ` Nuno Sá [this message]
2026-03-25 21:07 ` [PATCH v2 2/2] ASoC: adau1372: Fix clock leak on PLL lock failure Jihed Chaibi
2026-03-26  9:31   ` Nuno Sá
2026-03-26  9:31 ` [PATCH v2 0/2] ASoC: adau1372: Fix error handling in adau1372_set_power() Nuno Sá
2026-03-26  9:42   ` Jihed Chaibi
2026-03-26 10:33 ` Mark Brown

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=67b84d7381662363a300fc108d8111d777489a50.camel@gmail.com \
    --to=noname.nuno@gmail.com \
    --cc=broonie@kernel.org \
    --cc=jihed.chaibi.dev@gmail.com \
    --cc=lars@metafoo.de \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --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