diff mbox series

amdtp-stream: Checking a variable for zero before dividing

Message ID 20240323060338.663707-1-shum.sdl@nppct.ru
State New
Headers show
Series amdtp-stream: Checking a variable for zero before dividing | expand

Commit Message

Andrey Shumilin March 23, 2024, 6:03 a.m. UTC
The step variable is initialized to zero.
It changes in the loop, but if it doesn’t change
it will remain zero.
The patch added a variable check.

Found by Linux Verification Center (linuxtesting.org) with SVACE.
Signed-off-by: Andrey Shumilin <shum.sdl@nppct.ru>
---
 sound/firewire/amdtp-stream.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c
index c9f153f85ae6..b61aa30f43a9 100644
--- a/sound/firewire/amdtp-stream.c
+++ b/sound/firewire/amdtp-stream.c
@@ -168,7 +168,8 @@  static int apply_constraint_to_size(struct snd_pcm_hw_params *params,
 		if (snd_interval_test(r, amdtp_rate_table[i]))
 			step = max(step, amdtp_syt_intervals[i]);
 	}
-
+	if (step == 0)
+		return -EINVAL;
 	t.min = roundup(s->min, step);
 	t.max = rounddown(s->max, step);
 	t.integer = 1;