From: Dan Carpenter <dan.carpenter@oracle.com>
To: "James E.J. Bottomley" <jejb@parisc-linux.org>
Cc: Helge Deller <deller@gmx.de>,
linux-parisc@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [patch v2] parisc: perf: return -EFAULT on error
Date: Sat, 10 Dec 2016 09:06:25 +0000 [thread overview]
Message-ID: <20161210090625.GA12892@elgon.mountain> (raw)
In-Reply-To: <CAOmT4fTi+7r=1OJsumVC_+ET-NXcGjsZ5+t5ppm0eZZ2VeuF-A@mail.gmail.com>
The copy_from_user() returns the number of bytes remaining to be copied
but we want to return -EFAULT if it's non-zero.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: Fix unused variable warning. Thanks, Bojan.
diff --git a/arch/parisc/kernel/perf.c b/arch/parisc/kernel/perf.c
index 518f4f5f1f43..6eabce62463b 100644
--- a/arch/parisc/kernel/perf.c
+++ b/arch/parisc/kernel/perf.c
@@ -301,7 +301,6 @@ static ssize_t perf_read(struct file *file, char __user *buf, size_t cnt, loff_t
static ssize_t perf_write(struct file *file, const char __user *buf, size_t count,
loff_t *ppos)
{
- int err;
size_t image_size;
uint32_t image_type;
uint32_t interface_type;
@@ -320,8 +319,8 @@ static ssize_t perf_write(struct file *file, const char __user *buf, size_t coun
if (count != sizeof(uint32_t))
return -EIO;
- if ((err = copy_from_user(&image_type, buf, sizeof(uint32_t))) != 0)
- return err;
+ if (copy_from_user(&image_type, buf, sizeof(uint32_t)))
+ return -EFAULT;
/* Get the interface type and test type */
interface_type = (image_type >> 16) & 0xffff;
next prev parent reply other threads:[~2016-12-10 9:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-08 11:32 [patch] parisc: perf: return -EFAULT on error Dan Carpenter
2016-12-08 14:53 ` bojan prtvar
2016-12-08 15:10 ` Dan Carpenter
2016-12-10 9:06 ` Dan Carpenter [this message]
2016-12-10 20:40 ` [patch v2] " Helge Deller
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=20161210090625.GA12892@elgon.mountain \
--to=dan.carpenter@oracle.com \
--cc=deller@gmx.de \
--cc=jejb@parisc-linux.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-parisc@vger.kernel.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