summaryrefslogtreecommitdiff
path: root/asoc
diff options
context:
space:
mode:
authorLaxminath Kasam <lkasam@codeaurora.org>2021-01-20 11:17:22 +0530
committerGerrit - the friendly Code Review server <code-review@localhost>2021-01-29 21:46:02 -0800
commit989605a308e760bc4e65bf8a70eace857c627535 (patch)
tree2f8ce57636e70363e82a8461c4141a8193761762 /asoc
parent27e8e9bf68f7d2cc23f7d42407a213a03e3faaa5 (diff)
downloadmsm-extra-989605a308e760bc4e65bf8a70eace857c627535.tar.gz
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>
Diffstat (limited to 'asoc')
-rw-r--r--asoc/msm-pcm-q6-v2.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/asoc/msm-pcm-q6-v2.c b/asoc/msm-pcm-q6-v2.c
index de8519d1..e6a5c1a7 100644
--- a/asoc/msm-pcm-q6-v2.c
+++ b/asoc/msm-pcm-q6-v2.c
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-only
-/* Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2021, The Linux Foundation. All rights reserved.
*/
@@ -1009,7 +1009,10 @@ static int msm_pcm_capture_copy(struct snd_pcm_substream *substream,
pr_debug("Offset value = %d\n", offset);
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)) {