summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Fitzgerald <rf@opensource.cirrus.com>2026-05-12 13:31:26 +0100
committerMark Brown <broonie@kernel.org>2026-05-12 22:21:37 +0900
commit7d572b75d54edeb48135f8b029cfdec41277e30f (patch)
treedf87b586529601cbf58e658087a97ea2d88cc84b
parentca1063ae03dcbf893dcd196ff073f9e7b5df8ccf (diff)
downloadlinux-7d572b75d54edeb48135f8b029cfdec41277e30f.tar.gz
linux-7d572b75d54edeb48135f8b029cfdec41277e30f.zip
ASoC: cs35l56: Abort TDM mask loop at maximum channel shift
Exit the for_each_set_bit() loop in cs35l56_make_tdm_config_word() after all possible channel shifts have been done. This prevents going around the loop with out-of-range shift values, which is technically undefined behaviour. It also shuts up code analysis tools. Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://patch.msgid.link/20260512123126.260148-1-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/codecs/cs35l56.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/sound/soc/codecs/cs35l56.c b/sound/soc/codecs/cs35l56.c
index 849d70ca23d6..0318cfd87943 100644
--- a/sound/soc/codecs/cs35l56.c
+++ b/sound/soc/codecs/cs35l56.c
@@ -426,6 +426,8 @@ static unsigned int cs35l56_make_tdm_config_word(unsigned int reg_val, unsigned
reg_val &= ~(0x3f << channel_shift);
reg_val |= bit_num << channel_shift;
channel_shift += 8;
+ if (channel_shift > 24)
+ break;
}
return reg_val;