* [PATCH] ASoC: cs48l32: Fix a signedness bug in cs48l32_hw_params()
@ 2025-06-03 21:48 Harshit Mogalapalli
2025-06-06 10:00 ` Richard Fitzgerald
2025-06-09 13:40 ` Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Harshit Mogalapalli @ 2025-06-03 21:48 UTC (permalink / raw)
To: David Rhodes, Richard Fitzgerald, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, Stuart Henderson,
Piotr Stankiewicz, Qi Zhou, linux-sound, patches, linux-kernel
Cc: dan.carpenter, kernel-janitors, error27, harshit.m.mogalapalli
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: e2bcbf99d045 ("ASoC: cs48l32: Add driver for Cirrus Logic CS48L32 audio DSP")
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
---
This is found using static analysis with Smatch, only compile tested.
---
sound/soc/codecs/cs48l32.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/sound/soc/codecs/cs48l32.c b/sound/soc/codecs/cs48l32.c
index 90a795230d27..9bdd48aab42a 100644
--- a/sound/soc/codecs/cs48l32.c
+++ b/sound/soc/codecs/cs48l32.c
@@ -2162,6 +2162,10 @@ static int cs48l32_hw_params(struct snd_pcm_substream *substream,
n_slots_multiple = 1;
sclk_target = snd_soc_tdm_params_to_bclk(params, slotw, n_slots, n_slots_multiple);
+ if (sclk_target < 0) {
+ cs48l32_asp_err(dai, "Invalid parameters\n");
+ return sclk_target;
+ }
for (i = 0; i < ARRAY_SIZE(cs48l32_sclk_rates); i++) {
if ((cs48l32_sclk_rates[i].freq >= sclk_target) &&
--
2.39.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ASoC: cs48l32: Fix a signedness bug in cs48l32_hw_params()
2025-06-03 21:48 [PATCH] ASoC: cs48l32: Fix a signedness bug in cs48l32_hw_params() Harshit Mogalapalli
@ 2025-06-06 10:00 ` Richard Fitzgerald
2025-06-09 13:40 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Richard Fitzgerald @ 2025-06-06 10:00 UTC (permalink / raw)
To: Harshit Mogalapalli, David Rhodes, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, Stuart Henderson,
Piotr Stankiewicz, Qi Zhou, linux-sound, patches, linux-kernel
Cc: dan.carpenter, kernel-janitors, error27
On 03/06/2025 10:48 pm, Harshit Mogalapalli wrote:
> 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: e2bcbf99d045 ("ASoC: cs48l32: Add driver for Cirrus Logic CS48L32 audio DSP")
> Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Reviewed-by: Richard Fitzgerald <rf@opensource.cirrus.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ASoC: cs48l32: Fix a signedness bug in cs48l32_hw_params()
2025-06-03 21:48 [PATCH] ASoC: cs48l32: Fix a signedness bug in cs48l32_hw_params() Harshit Mogalapalli
2025-06-06 10:00 ` Richard Fitzgerald
@ 2025-06-09 13:40 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2025-06-09 13:40 UTC (permalink / raw)
To: David Rhodes, Richard Fitzgerald, Liam Girdwood, Jaroslav Kysela,
Takashi Iwai, Stuart Henderson, Piotr Stankiewicz, Qi Zhou,
linux-sound, patches, linux-kernel, Harshit Mogalapalli
Cc: dan.carpenter, kernel-janitors, error27
On Tue, 03 Jun 2025 14:48:13 -0700, Harshit Mogalapalli wrote:
> 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.
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/1] ASoC: cs48l32: Fix a signedness bug in cs48l32_hw_params()
commit: 22188b9df60dde48eaba276da22062aaf8e12dfe
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-06-09 13:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-03 21:48 [PATCH] ASoC: cs48l32: Fix a signedness bug in cs48l32_hw_params() Harshit Mogalapalli
2025-06-06 10:00 ` Richard Fitzgerald
2025-06-09 13:40 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).