* [PATCH] ASoC: loongson: Check sysclk in hw_params
@ 2026-11-30 2:14 Li Jun
2026-11-30 2:19 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Li Jun @ 2026-11-30 2:14 UTC (permalink / raw)
To: lijun01, zhoubinbin, lgirdwood, broonie, perex, tiwai,
linux-sound
loongson_i2s_hw_params() uses i2s->sysclk as a divisor when computing
the bclk and mclk ratios, so a zero sysclk would cause a division by
zero.
Return -EINVAL before the revision switch when sysclk is zero.
Signed-off-by: Li Jun <lijun01@kylinos.cn>
---
sound/soc/loongson/loongson_i2s.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/sound/soc/loongson/loongson_i2s.c b/sound/soc/loongson/loongson_i2s.c
index 438bbae0888f..76741ec139fe 100644
--- a/sound/soc/loongson/loongson_i2s.c
+++ b/sound/soc/loongson/loongson_i2s.c
@@ -73,6 +73,11 @@ static int loongson_i2s_hw_params(struct snd_pcm_substream *substream,
u32 mask;
u32 val = 0;
+ if (!sysclk) {
+ dev_err(i2s->dev, "invalid sysclk\n");
+ return -EINVAL;
+ }
+
switch (i2s->rev_id) {
case 0:
bclk_ratio = DIV_ROUND_CLOSEST(clk_rate,
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ASoC: loongson: Check sysclk in hw_params
2026-11-30 2:14 [PATCH] ASoC: loongson: Check sysclk in hw_params Li Jun
@ 2026-11-30 2:19 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-30 2:19 UTC (permalink / raw)
To: Li Jun, linux-sound
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] ASoC: loongson: missing Fixes trailer for division-by-zero fix
--
commit 958731b075dc9cfcb85d64095ac9fa6380a9b0a0
Author: Li Jun <lijun01@kylinos.cn>
> ASoC: loongson: Check sysclk in hw_params
>
> loongson_i2s_hw_params() uses i2s->sysclk as a divisor when computing
> the bclk and mclk ratios, so a zero sysclk would cause a division by
> zero.
> Return -EINVAL before the revision switch when sysclk is zero.
>
> Signed-off-by: Li Jun <lijun01@kylinos.cn>
[Severity: Low]
This fixes a division-by-zero bug in loongson_i2s_hw_params(). Should
the commit message include:
Fixes: d84881e06836 ("ASoC: Add support for Loongson I2S controller")
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261130021409.193149-1-lijun01@kylinos.cn?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-30 2:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 2:14 [PATCH] ASoC: loongson: Check sysclk in hw_params Li Jun
2026-11-30 2:19 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox