diff mbox

parisc: perf: return -EFAULT on error

Message ID 20161208113200.GC11382@elgon.mountain (mailing list archive)
State Superseded
Headers show

Commit Message

Dan Carpenter Dec. 8, 2016, 11:32 a.m. UTC
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>

--
To unsubscribe from this list: send the line "unsubscribe linux-parisc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Bojan Prtvar Dec. 8, 2016, 2:53 p.m. UTC | #1
Hi Dan,

On Thu, Dec 8, 2016 at 12:32 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> -       if ((err = copy_from_user(&image_type, buf, sizeof(uint32_t))) != 0)
> -               return err;

Why not delete err?

Regards,
Bojan
--
To unsubscribe from this list: send the line "unsubscribe linux-parisc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Dan Carpenter Dec. 8, 2016, 3:10 p.m. UTC | #2
On Thu, Dec 08, 2016 at 03:53:42PM +0100, bojan prtvar wrote:
> Hi Dan,
> 
> On Thu, Dec 8, 2016 at 12:32 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> > -       if ((err = copy_from_user(&image_type, buf, sizeof(uint32_t))) != 0)
> > -               return err;
> 
> Why not delete err?

Gar... I'm sorry.  I'll resend.

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe linux-parisc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/parisc/kernel/perf.c b/arch/parisc/kernel/perf.c
index 518f4f5f1f43..76c96a53fc71 100644
--- a/arch/parisc/kernel/perf.c
+++ b/arch/parisc/kernel/perf.c
@@ -320,8 +320,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;