Skip to content

Commit 0cac694

Browse files
cgrogregkh
authored andcommitted
staging: most: sound: add sanity check for function argument
[ Upstream commit 45b754a ] This patch checks the function parameter 'bytes' before doing the subtraction to prevent memory corruption. Signed-off-by: Christian Gromm <christian.gromm@microchip.com> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Link: https://lore.kernel.org/r/1612282865-21846-1-git-send-email-christian.gromm@microchip.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 15c56b8 commit 0cac694

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

drivers/staging/most/sound/sound.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ static void swap_copy24(u8 *dest, const u8 *source, unsigned int bytes)
9696
{
9797
unsigned int i = 0;
9898

99+
if (bytes < 2)
100+
return;
99101
while (i < bytes - 2) {
100102
dest[i] = source[i + 2];
101103
dest[i + 1] = source[i + 1];

0 commit comments

Comments
 (0)