Skip to content

Commit 5588b7c

Browse files
avasummergregkh
authored andcommitted
ALSA: wavefront: Fix integer overflow in sample size validation
commit 0c4a13b upstream. The wavefront_send_sample() function has an integer overflow issue when validating sample size. The header->size field is u32 but gets cast to int for comparison with dev->freemem Fix by using unsigned comparison to avoid integer overflow. Fixes: 1da177e ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Signed-off-by: Junrui Luo <moonafterrain@outlook.com> Link: https://patch.msgid.link/SYBPR01MB7881B47789D1B060CE8BF4C3AFC2A@SYBPR01MB7881.ausprd01.prod.outlook.com Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c0a1fe1 commit 5588b7c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sound/isa/wavefront/wavefront_synth.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -950,9 +950,9 @@ wavefront_send_sample (snd_wavefront_t *dev,
950950
if (header->size) {
951951
dev->freemem = wavefront_freemem (dev);
952952

953-
if (dev->freemem < (int)header->size) {
953+
if (dev->freemem < 0 || dev->freemem < header->size) {
954954
dev_err(dev->card->dev,
955-
"insufficient memory to load %d byte sample.\n",
955+
"insufficient memory to load %u byte sample.\n",
956956
header->size);
957957
return -ENOMEM;
958958
}

0 commit comments

Comments
 (0)