From: Dan Carpenter <dan.carpenter@oracle.com>
To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
Srinivasa Rao Mandadapu <quic_srivasam@quicinc.com>
Cc: "Banajit Goswami" <bgoswami@codeaurora.org>,
"Liam Girdwood" <lgirdwood@gmail.com>,
"Mark Brown" <broonie@kernel.org>,
"Jaroslav Kysela" <perex@perex.cz>,
"Takashi Iwai" <tiwai@suse.com>,
"Sumit Semwal" <sumit.semwal@linaro.org>,
"Christian König" <christian.koenig@amd.com>,
alsa-devel@alsa-project.org, linux-media@vger.kernel.org,
dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org,
kernel-janitors@vger.kernel.org
Subject: [PATCH] ASoC: qcom: Fix error code in lpass_platform_copy()
Date: Tue, 1 Mar 2022 11:11:04 +0300 [thread overview]
Message-ID: <20220301081104.GB17375@kili> (raw)
The copy_to/from_user() functions return the number of bytes remaining
to be copied. This function needs to return negative error codes
because snd_soc_pcm_component_copy_user() treats positive returns as
success in soc_component_ret().
Fixes: 7d7209557b67 ("ASoC: qcom: Add support for codec dma driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
sound/soc/qcom/lpass-platform.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/sound/soc/qcom/lpass-platform.c b/sound/soc/qcom/lpass-platform.c
index bf180a594c19..620312529c2f 100644
--- a/sound/soc/qcom/lpass-platform.c
+++ b/sound/soc/qcom/lpass-platform.c
@@ -1228,15 +1228,19 @@ static int lpass_platform_copy(struct snd_soc_component *component,
channel * (rt->dma_bytes / rt->channels));
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
- if (is_cdc_dma_port(dai_id))
+ if (is_cdc_dma_port(dai_id)) {
ret = copy_from_user_toio(dma_buf, buf, bytes);
- else
- ret = copy_from_user((void __force *)dma_buf, buf, bytes);
+ } else {
+ if (copy_from_user((void __force *)dma_buf, buf, bytes))
+ ret = -EFAULT;
+ }
} else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
- if (is_cdc_dma_port(dai_id))
+ if (is_cdc_dma_port(dai_id)) {
ret = copy_to_user_fromio(buf, dma_buf, bytes);
- else
- ret = copy_to_user(buf, (void __force *)dma_buf, bytes);
+ } else {
+ if (copy_to_user(buf, (void __force *)dma_buf, bytes))
+ ret = -EFAULT;
+ }
}
return ret;
--
2.20.1
reply other threads:[~2022-03-01 8:12 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220301081104.GB17375@kili \
--to=dan.carpenter@oracle.com \
--cc=alsa-devel@alsa-project.org \
--cc=bgoswami@codeaurora.org \
--cc=broonie@kernel.org \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-media@vger.kernel.org \
--cc=perex@perex.cz \
--cc=quic_srivasam@quicinc.com \
--cc=srinivas.kandagatla@linaro.org \
--cc=sumit.semwal@linaro.org \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox