Skip to contentSkip to conversation

parisc: perf: return -EFAULT on error

PATCH Superseded Dan Carpenter 3 participants 5 messages Dec 8, 2016 – Dec 10, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 parisc: perf: return -EFAULT on error

The copy_from_user() returns the number of bytes remaining to be copied but we want to return -EFAULT if it's non-zero.

arch/parisc/kernel/perf.c +2 -2
index 518f4f5f1f43..76c96a53fc71 100644
@@ -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;
#1 lore raw

Hi Dan,

arch/parisc/kernel/perf.c static ssize_t perf_write(struct file *file, const char __user *buf, size_t coun · line 324

Quoted 2 lines · Dan Carpenter
arch/parisc/kernel/perf.c +0 -2
-       if ((err = copy_from_user(&image_type, buf, sizeof(uint32_t))) != 0)
-               return err;

Why not delete err?

Regards,
Bojan

#2 lore raw
Quoted 7 lines · bojan prtvar

Hi Dan,

arch/parisc/kernel/perf.c static ssize_t perf_write(struct file *file, const char __user *buf, size_t coun · line 324

Quoted 2 lines · Dan Carpenter
arch/parisc/kernel/perf.c +0 -2
-       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

#3 lore raw

PATCH v2 1/1 parisc: perf: return -EFAULT on error

In reply to bojan prtvar

The copy_from_user() returns the number of bytes remaining to be copied but we want to return -EFAULT if it's non-zero.

---
v2: Fix unused variable warning. Thanks, Bojan.

arch/parisc/kernel/perf.c +2 -3
index 518f4f5f1f43..6eabce62463b 100644
@@ -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;
maintainer
#4 lore raw
Quoted 4 lines · Dan Carpenter

The copy_from_user() returns the number of bytes remaining to be copied but we want to return -EFAULT if it's non-zero.

Thanks Dan!
I'll add it to my next push request for the parisc architecture.

Helge

Quoted 31 lines

---
v2: Fix unused variable warning. Thanks, Bojan.

arch/parisc/kernel/perf.c +2 -4
index 518f4f5f1f43..6eabce62463b 100644
@@ -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;
--

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