Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 989605a3 authored by Laxminath Kasam's avatar Laxminath Kasam Committed by Gerrit - the friendly Code Review server
Browse files

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: default avatarLaxminath Kasam <lkasam@codeaurora.org>
parent 27e8e9bf
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
// 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);
			if (fbytes > prtd->pcm_count)
				size = xfer = prtd->pcm_count;
			else
				size = xfer = fbytes;
		}

		if (copy_to_user(buf, bufptr+offset, xfer)) {