summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorSiena Richard <sienar@codeaurora.org>2017-01-31 12:21:38 -0800
committerGerrit - the friendly Code Review server <code-review@localhost>2017-02-21 12:53:31 -0800
commitcd8d41ed1e510e590db45a971d7c2c2cb59a1e3b (patch)
tree9f00f93b309001fe41a77d1f4b7457c6fe2696dd /sound
parentc4b8f7345591598bccc856150c65d787e894c039 (diff)
ASoC: msm: qdsp6v2: return error when copy from userspace fails
A copy_from_user is not always expected to succeed. Therefore, check for an error before operating on the buffer post copy. CRs-Fixed: 1116070 Change-Id: I21032719e6e85f280ca0cda875c84ac8dee8916b Signed-off-by: Siena Richard <sienar@codeaurora.org>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/msm/qdsp6v2/msm-pcm-voip-v2.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-voip-v2.c b/sound/soc/msm/qdsp6v2/msm-pcm-voip-v2.c
index c444a27c06e6..b2387a746f61 100644
--- a/sound/soc/msm/qdsp6v2/msm-pcm-voip-v2.c
+++ b/sound/soc/msm/qdsp6v2/msm-pcm-voip-v2.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -814,20 +814,25 @@ static int msm_pcm_playback_copy(struct snd_pcm_substream *substream, int a,
if (prtd->mode == MODE_PCM) {
ret = copy_from_user(&buf_node->frame.voc_pkt,
buf, count);
+ if (ret) {
+ pr_err("%s: copy from user failed %d\n",
+ __func__, ret);
+ return -EFAULT;
+ }
buf_node->frame.pktlen = count;
} else {
ret = copy_from_user(&buf_node->frame,
buf, count);
+ if (ret) {
+ pr_err("%s: copy from user failed %d\n",
+ __func__, ret);
+ return -EFAULT;
+ }
if (buf_node->frame.pktlen >= count)
buf_node->frame.pktlen = count -
(sizeof(buf_node->frame.frm_hdr) +
sizeof(buf_node->frame.pktlen));
}
- if (ret) {
- pr_err("%s: copy from user failed %d\n",
- __func__, ret);
- return -EFAULT;
- }
spin_lock_irqsave(&prtd->dsp_lock, dsp_flags);
list_add_tail(&buf_node->list, &prtd->in_queue);
spin_unlock_irqrestore(&prtd->dsp_lock, dsp_flags);