]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ASoC: cs35l56: Abort TDM mask loop at maximum channel shift
authorRichard Fitzgerald <rf@opensource.cirrus.com>
Tue, 12 May 2026 12:31:26 +0000 (13:31 +0100)
committerMark Brown <broonie@kernel.org>
Tue, 12 May 2026 13:21:37 +0000 (22:21 +0900)
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>
sound/soc/codecs/cs35l56.c

index 849d70ca23d6f544991f68046fceca3a99593e74..0318cfd87943f5b2d68956c4a1f16b78cb266908 100644 (file)
@@ -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;