diff options
author | Christian Gromm <christian.gromm@microchip.com> | 2021-02-02 19:21:05 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-03-07 14:34:10 +0300 |
commit | 0cac694c2c05506fd84660be26225f0b2a2276c7 (patch) | |
tree | a2d061fcfaf10e6e486fdb7b1023b53e822a2dab /drivers/staging/most | |
parent | 15c56b8f2ce1b09b71f8ec4a1a977af3846d00a7 (diff) | |
download | linux-0cac694c2c05506fd84660be26225f0b2a2276c7.tar.xz |
staging: most: sound: add sanity check for function argument
[ Upstream commit 45b754ae5b82949dca2b6e74fa680313cefdc813 ]
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>
Diffstat (limited to 'drivers/staging/most')
-rw-r--r-- | drivers/staging/most/sound/sound.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/staging/most/sound/sound.c b/drivers/staging/most/sound/sound.c index 8a449ab9bdce..b7666a7b1760 100644 --- a/drivers/staging/most/sound/sound.c +++ b/drivers/staging/most/sound/sound.c @@ -96,6 +96,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]; |