Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: stm: stm32_i2s: Fix calc_clk_div() error handling in determine_rate()

calc_clk_div() will only return a non-zero value (-EINVAL)
in case of error. On the other hand, req->rate is an unsigned long.
It seems quite odd that req->rate would be assigned a negative value,
which is clearly not a rate, and success would be returned.

Reinstate previous logic, which would just return error.

Fixes: afd529d74002 ("ASoC: stm: stm32_i2s: convert from round_rate() to determine_rate()")
Link: https://scan7.scan.coverity.com/#/project-view/53936/11354?selectedIssue=1647702

Signed-off-by: Sergio Perez Gonzalez <sperezglz@gmail.com>
Link: https://patch.msgid.link/20250729020052.404617-1-sperezglz@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Sergio Perez Gonzalez and committed by
Mark Brown
0ebbab41 dcb82900

+2 -5
+2 -5
sound/soc/stm/stm32_i2s.c
··· 469 469 int ret; 470 470 471 471 ret = stm32_i2s_calc_clk_div(i2s, req->best_parent_rate, req->rate); 472 - if (ret) { 473 - req->rate = ret; 474 - 475 - return 0; 476 - } 472 + if (ret) 473 + return ret; 477 474 478 475 mclk->freq = req->best_parent_rate / i2s->divider; 479 476