Skip to contentSkip to conversation

ASoC: cs35l36: Handle zero sysclk frequency

PATCH In review Alex Kazinsky 3 participants 3 messages Oct 30 – Nov 2

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: cs35l36: Handle zero sysclk frequency

simple_util_shutdown() calls snd_soc_dai_set_sysclk() with a zero frequency when mclk-fs is configured, the clock is not fixed and the last active stream on the DAI is closed.

cs35l36_dai_set_sysclk() passes this frequency to DIV_ROUND_UP() when calculating the FS monitor windows, resulting in division by zero.

Return success without updating the FS monitor windows when the frequency is zero, as there is no running clock to monitor.

Found by Linux Verification Center (linuxtesting.org) with SVACE static analysis tool.

Fixes 6ba9dd6c893b ("ASoC: cs35l36: Add support for Cirrus CS35L36 Amplifier")
---
 sound/soc/codecs/cs35l36.c | 3 +++
 1 file changed, 3 insertions(+)
sound/soc/codecs/cs35l36.c +3 -0
index 5fc8ec292e3c..266b95397873 100644
@@ -910,6 +910,9 @@ static int cs35l36_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id,
 			snd_soc_component_get_drvdata(component);
 	int fs1, fs2;
 
+	if (!freq)
+		return 0;
+
 	if (freq > CS35L36_FS_NOM_6MHZ) {
 		fs1 = CS35L36_FS1_DEFAULT_VAL;
 		fs2 = CS35L36_FS2_DEFAULT_VAL;
Signature · 1 line
2.56.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Alex Kazinsky

simple_util_shutdown() calls snd_soc_dai_set_sysclk() with a zero frequency when mclk-fs is configured, the clock is not fixed and the last active stream on the DAI is closed.

cs35l36_dai_set_sysclk() passes this frequency to DIV_ROUND_UP() when calculating the FS monitor windows, resulting in division by zero.

Return success without updating the FS monitor windows when the frequency is zero, as there is no running clock to monitor.

Quoted 7 lines

Found by Linux Verification Center (linuxtesting.org) with SVACE static analysis tool.

Fixes 6ba9dd6c893b ("ASoC: cs35l36: Add support for Cirrus CS35L36 Amplifier")

---

Thanks,
Charles

maintainer
#2 lore raw
In reply to Alex Kazinsky
Quoted 1 line · Alex Kazinsky

ASoC: cs35l36: Handle zero sysclk frequency

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.5

Thanks!

[1/1] ASoC: cs35l36: Handle zero sysclk frequency

      https://git.kernel.org/broonie/sound/c/415f0a7c723f

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark