From: "Nuno Sá" <nuno.sa@analog.com>
To: Li Jun <lijun01@kylinos.cn>
Cc: lars@metafoo.de, lgirdwood@gmail.com, broonie@kernel.org,
perex@perex.cz, tiwai@suse.com, linux-sound@vger.kernel.org
Subject: Re: [PATCH] ASoC: adau-utils: Fix divide-by-zero when freq_in is zero
Date: Wed, 2 Dec 2026 11:33:25 +0000 [thread overview]
Message-ID: <axAB4wmUQI1q95Cw@nsa> (raw)
In-Reply-To: <20261202092812.2283516-1-lijun01@kylinos.cn>
On Wed, Dec 02, 2026 at 05:28:12PM +0800, Li Jun wrote:
> adau_calc_pll_cfg() uses freq_in as a divisor without validating it.
> With a non-zero freq_out and freq_in = 0, freq_out % freq_in causes a
> divide-by-zero exception.
> Both adau17x1 and adau1372 call the helper at probe time with the rate
> returned by clk_get_rate(), in clk_get_rate():
> if (!clk)
> return 0;
> if the rate returned by clk_get_rate() is 0, call adau_calc_pll_cfg in
> adau17x1_probe and adau1372_setup_pll causes a divide-by-zero.
>
> Fixes: 0eadaa9ce2aa ("ASoC: adau: Factor out shared PLL configuration code")
> Signed-off-by: Li Jun <lijun01@kylinos.cn>
> ---
Ok, seems like a valid improvement:
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
> sound/soc/codecs/adau-utils.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/sound/soc/codecs/adau-utils.c b/sound/soc/codecs/adau-utils.c
> index 836940f2ab92..875dea223ee5 100644
> --- a/sound/soc/codecs/adau-utils.c
> +++ b/sound/soc/codecs/adau-utils.c
> @@ -24,6 +24,9 @@ int adau_calc_pll_cfg(unsigned int freq_in, unsigned int freq_out,
> m = 0;
> div = 0;
> } else {
> + if (!freq_in)
> + return -EINVAL;
> +
> if (freq_out % freq_in != 0) {
> div = DIV_ROUND_UP(freq_in, 13500000);
> freq_in /= div;
> --
> 2.25.1
>
prev parent reply other threads:[~2026-12-02 11:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 9:28 [PATCH] ASoC: adau-utils: Fix divide-by-zero when freq_in is zero Li Jun
2026-12-02 11:33 ` Nuno Sá [this message]
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=axAB4wmUQI1q95Cw@nsa \
--to=nuno.sa@analog.com \
--cc=broonie@kernel.org \
--cc=lars@metafoo.de \
--cc=lgirdwood@gmail.com \
--cc=lijun01@kylinos.cn \
--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