summaryrefslogtreecommitdiff
path: root/drivers/sound
diff options
context:
space:
mode:
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>2022-12-04 16:00:05 +0300
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>2022-12-05 19:43:21 +0300
commitd0e8777beeb675b77d6b2bf679133106892eb8dd (patch)
tree6986a7653c006895bd23fc7b9eef06dd3749f08a /drivers/sound
parenta50622d78c5c6babd1853ae913f339df54fe532c (diff)
downloadu-boot-d0e8777beeb675b77d6b2bf679133106892eb8dd.tar.xz
sound: avoid endless loop
'sound play 1 100000' results in an endless loop on the sandbox. If the frequency exceeds half the sampling rate, zero out the output buffer. Fixes: 511ed5fdd389 ("SOUND: SAMSUNG: Add I2S driver") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/sound')
-rw-r--r--drivers/sound/sound.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/sound/sound.c b/drivers/sound/sound.c
index 041dfdccfe..c0fc50c99d 100644
--- a/drivers/sound/sound.c
+++ b/drivers/sound/sound.c
@@ -15,7 +15,10 @@ void sound_create_square_wave(uint sample_rate, unsigned short *data, int size,
const int period = freq ? sample_rate / freq : 0;
const int half = period / 2;
- assert(freq);
+ if (!half) {
+ memset(data, 0, size);
+ return;
+ }
/* Make sure we don't overflow our buffer */
if (size % 2)