[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20240323060338.663707-1-shum.sdl@nppct.ru>
Date: Sat, 23 Mar 2024 09:03:38 +0300
From: Andrey Shumilin <shum.sdl@...ct.ru>
To: Clemens Ladisch <clemens@...isch.de>
Cc: Andrey Shumilin <shum.sdl@...ct.ru>,
Takashi Sakamoto <o-takashi@...amocchi.jp>,
Jaroslav Kysela <perex@...ex.cz>,
Takashi Iwai <tiwai@...e.com>,
alsa-devel@...a-project.org,
linux-sound@...r.kernel.org,
linux-kernel@...r.kernel.org,
lvc-project@...uxtesting.org,
khoroshilov@...ras.ru,
ykarpov@...ras.ru,
vmerzlyakov@...ras.ru,
vefanov@...ras.ru
Subject: [PATCH] amdtp-stream: Checking a variable for zero before dividing
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@...ct.ru>
---
sound/firewire/amdtp-stream.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
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;
--
2.30.2
Powered by blists - more mailing lists