summaryrefslogtreecommitdiff
path: root/drivers/staging/most
diff options
context:
space:
mode:
authorChristian Gromm <christian.gromm@microchip.com>2021-02-02 17:21:05 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-02-04 17:13:46 +0100
commit45b754ae5b82949dca2b6e74fa680313cefdc813 (patch)
tree4dd3b1d491a1bb86d1a7a7835a4b80a676f3738d /drivers/staging/most
parent06b0c0dce88e2aa2f01343db0f26d214d7f264a0 (diff)
staging: most: sound: add sanity check for function argument
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>
Diffstat (limited to 'drivers/staging/most')
-rw-r--r--drivers/staging/most/sound/sound.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/staging/most/sound/sound.c b/drivers/staging/most/sound/sound.c
index 3a1a59058042..45befb8c1126 100644
--- a/drivers/staging/most/sound/sound.c
+++ b/drivers/staging/most/sound/sound.c
@@ -86,6 +86,8 @@ static void swap_copy24(u8 *dest, const u8 *source, unsigned int bytes)
{
unsigned int i = 0;
+ if (bytes < 2)
+ return;
while (i < bytes - 2) {
dest[i] = source[i + 2];
dest[i + 1] = source[i + 1];