Skip to content

Commit 22188b9

Browse files
harshimogalapallibroonie
authored andcommitted
ASoC: cs48l32: Fix a signedness bug in cs48l32_hw_params()
There is a type promotion that can happen when freq(u32) variable is comapared with sclk_target(integer), when sclk_target is a negative value it promotes to a large postive integer which might not be a problem in this particular case as the condition evaluates to false when that happens, but bail out early when sclk_target has negative error codes. cs48l32_sclk_rates[i].freq >= sclk_target Fix this by adding a negative error check when snd_soc_tdm_params_to_bclk() fails Fixes: e2bcbf9 ("ASoC: cs48l32: Add driver for Cirrus Logic CS48L32 audio DSP") Signed-off-by: Harshit Mogalapalli <[email protected]> Link: https://patch.msgid.link/[email protected] Reviewed-by: Richard Fitzgerald <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent 19272b3 commit 22188b9

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

sound/soc/codecs/cs48l32.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2162,6 +2162,10 @@ static int cs48l32_hw_params(struct snd_pcm_substream *substream,
21622162
n_slots_multiple = 1;
21632163

21642164
sclk_target = snd_soc_tdm_params_to_bclk(params, slotw, n_slots, n_slots_multiple);
2165+
if (sclk_target < 0) {
2166+
cs48l32_asp_err(dai, "Invalid parameters\n");
2167+
return sclk_target;
2168+
}
21652169

21662170
for (i = 0; i < ARRAY_SIZE(cs48l32_sclk_rates); i++) {
21672171
if ((cs48l32_sclk_rates[i].freq >= sclk_target) &&

0 commit comments

Comments
 (0)