public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: nikai@nikai.net (Nicolas Kaiser)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] dma/coh901318: fix copy_to_user error path
Date: Fri, 22 Oct 2010 19:29:53 +0200	[thread overview]
Message-ID: <20101022192953.1f67b10a@absol.kitzblitz> (raw)

If copy_to_user fails, the assigned error code instantly gets
overwritten, and the failure apparently ignored. Moreover,
shouldn't the error code be -EFAULT instead of -EINVAL?

Signed-off-by: Nicolas Kaiser <nikai@nikai.net>
---
 drivers/dma/coh901318.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/coh901318.c b/drivers/dma/coh901318.c
index ae2b871..eac8867 100644
--- a/drivers/dma/coh901318.c
+++ b/drivers/dma/coh901318.c
@@ -140,8 +140,10 @@ static int coh901318_debugfs_read(struct file *file, char __user *buf,
 	if (count > dev_size - *f_pos)
 		count = dev_size - *f_pos;
 
-	if (copy_to_user(buf, dev_buf + *f_pos, count))
-		ret = -EINVAL;
+	if (copy_to_user(buf, dev_buf + *f_pos, count)) {
+		ret = -EFAULT;
+		goto out;
+	}
 	ret = count;
 	*f_pos += count;
 
-- 
1.7.2.2

             reply	other threads:[~2010-10-22 17:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-22 17:29 Nicolas Kaiser [this message]
2010-10-22 17:38 ` [PATCH] dma/coh901318: fix copy_to_user error path Arnd Bergmann
2010-10-22 18:30   ` [PATCH] dma/coh901318: use simple_read_from_buffer Nicolas Kaiser
2010-10-22 19:16     ` Arnd Bergmann

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=20101022192953.1f67b10a@absol.kitzblitz \
    --to=nikai@nikai.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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