linux-parisc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] parisc: perf: return -EFAULT on error
@ 2016-12-08 11:32 Dan Carpenter
  2016-12-08 14:53 ` bojan prtvar
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2016-12-08 11:32 UTC (permalink / raw)
  To: James E.J. Bottomley; +Cc: Helge Deller, linux-parisc, kernel-janitors

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>

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;

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [patch] parisc: perf: return -EFAULT on error
  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   ` [patch v2] " Dan Carpenter
  0 siblings, 2 replies; 5+ messages in thread
From: bojan prtvar @ 2016-12-08 14:53 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: James E.J. Bottomley, Helge Deller, linux-parisc, kernel-janitors

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch] parisc: perf: return -EFAULT on error
  2016-12-08 14:53 ` bojan prtvar
@ 2016-12-08 15:10   ` Dan Carpenter
  2016-12-10  9:06   ` [patch v2] " Dan Carpenter
  1 sibling, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2016-12-08 15:10 UTC (permalink / raw)
  To: bojan prtvar
  Cc: James E.J. Bottomley, Helge Deller, linux-parisc, kernel-janitors

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [patch v2] parisc: perf: return -EFAULT on error
  2016-12-08 14:53 ` bojan prtvar
  2016-12-08 15:10   ` Dan Carpenter
@ 2016-12-10  9:06   ` Dan Carpenter
  2016-12-10 20:40     ` Helge Deller
  1 sibling, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2016-12-10  9:06 UTC (permalink / raw)
  To: James E.J. Bottomley; +Cc: Helge Deller, linux-parisc, kernel-janitors

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;

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [patch v2] parisc: perf: return -EFAULT on error
  2016-12-10  9:06   ` [patch v2] " Dan Carpenter
@ 2016-12-10 20:40     ` Helge Deller
  0 siblings, 0 replies; 5+ messages in thread
From: Helge Deller @ 2016-12-10 20:40 UTC (permalink / raw)
  To: Dan Carpenter, James E.J. Bottomley; +Cc: linux-parisc, kernel-janitors

On 10.12.2016 10:06, Dan Carpenter wrote:
> 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>

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

Helge


> ---
> 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;
> --
> 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
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-12-10 20:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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   ` [patch v2] " Dan Carpenter
2016-12-10 20:40     ` Helge Deller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).