Linux Sound subsystem development
 help / color / mirror / Atom feed
* [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

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