summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaxminath Kasam <lkasam@codeaurora.org>2021-01-20 11:17:22 +0530
committerAlexander Grund <flamefire89@gmail.com>2023-12-23 19:58:21 +0100
commit3f326631f769f46ad0e215e6f4683c805ea61ef9 (patch)
treee7d07cbeacb6b9998ddf68ebb23b09303eda0124
parent00342495f3fdef61c9be3fc92e757e58d32ab5a7 (diff)
asoc: Update copy_to_user to requested buffer size
Avoid copy to user more than requested buffer size to avoid memory corruption. Change-Id: Ibf1607f777a358ebd16fd8b8728809afda34eba7 Signed-off-by: Laxminath Kasam <lkasam@codeaurora.org>
-rw-r--r--sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c b/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c
index 0b663d72394e..33a104c20bd1 100644
--- a/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c
+++ b/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2021, The Linux Foundation. All rights reserved.
* Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -1006,7 +1006,10 @@ static int msm_pcm_capture_copy(struct snd_pcm_substream *substream,
if (size == 0 || size < prtd->pcm_count) {
memset(bufptr + offset + size, 0, prtd->pcm_count - size);
- size = xfer = prtd->pcm_count;
+ if (fbytes > prtd->pcm_count)
+ size = xfer = prtd->pcm_count;
+ else
+ size = xfer = fbytes;
}
if (copy_to_user(buf, bufptr+offset, xfer)) {