linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] gpio: mockup: return -EFAULT if copy_from_user() fails
@ 2017-02-14 23:02 Dan Carpenter
  2017-02-15  9:16 ` Bartosz Golaszewski
  2017-02-23 13:52 ` Linus Walleij
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2017-02-14 23:02 UTC (permalink / raw)
  To: Bamvor Jian Zhang, Bartosz Golaszewski
  Cc: Linus Walleij, Alexandre Courbot, linux-gpio, kernel-janitors

copy_from_user() returns the number of bytes remaining to be copied but
we want to return negative error codes on failue.

Fixes: 9202ba2397d1 ("gpio: mockup: implement event injecting over debugfs")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
index 06dac72cb69c..d99338689213 100644
--- a/drivers/gpio/gpio-mockup.c
+++ b/drivers/gpio/gpio-mockup.c
@@ -197,7 +197,7 @@ static ssize_t gpio_mockup_event_write(struct file *file,
 	struct seq_file *sfile;
 	struct gpio_desc *desc;
 	struct gpio_chip *gc;
-	int status, val;
+	int val;
 	char buf;
 
 	sfile = file->private_data;
@@ -206,9 +206,8 @@ static ssize_t gpio_mockup_event_write(struct file *file,
 	chip = priv->chip;
 	gc = &chip->gc;
 
-	status = copy_from_user(&buf, usr_buf, 1);
-	if (status)
-		return status;
+	if (copy_from_user(&buf, usr_buf, 1))
+		return -EFAULT;
 
 	if (buf == '0')
 		val = 0;

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

* Re: [patch] gpio: mockup: return -EFAULT if copy_from_user() fails
  2017-02-14 23:02 [patch] gpio: mockup: return -EFAULT if copy_from_user() fails Dan Carpenter
@ 2017-02-15  9:16 ` Bartosz Golaszewski
  2017-02-23 13:52 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Bartosz Golaszewski @ 2017-02-15  9:16 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Bamvor Jian Zhang, Linus Walleij, Alexandre Courbot, linux-gpio,
	kernel-janitors

2017-02-15 0:02 GMT+01:00 Dan Carpenter <dan.carpenter@oracle.com>:
> copy_from_user() returns the number of bytes remaining to be copied but
> we want to return negative error codes on failue.
>
> Fixes: 9202ba2397d1 ("gpio: mockup: implement event injecting over debugfs")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
> index 06dac72cb69c..d99338689213 100644
> --- a/drivers/gpio/gpio-mockup.c
> +++ b/drivers/gpio/gpio-mockup.c
> @@ -197,7 +197,7 @@ static ssize_t gpio_mockup_event_write(struct file *file,
>         struct seq_file *sfile;
>         struct gpio_desc *desc;
>         struct gpio_chip *gc;
> -       int status, val;
> +       int val;
>         char buf;
>
>         sfile = file->private_data;
> @@ -206,9 +206,8 @@ static ssize_t gpio_mockup_event_write(struct file *file,
>         chip = priv->chip;
>         gc = &chip->gc;
>
> -       status = copy_from_user(&buf, usr_buf, 1);
> -       if (status)
> -               return status;
> +       if (copy_from_user(&buf, usr_buf, 1))
> +               return -EFAULT;
>
>         if (buf == '0')
>                 val = 0;

Oops my bad.

Acked-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>

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

* Re: [patch] gpio: mockup: return -EFAULT if copy_from_user() fails
  2017-02-14 23:02 [patch] gpio: mockup: return -EFAULT if copy_from_user() fails Dan Carpenter
  2017-02-15  9:16 ` Bartosz Golaszewski
@ 2017-02-23 13:52 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2017-02-23 13:52 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Bamvor Jian Zhang, Bartosz Golaszewski, Alexandre Courbot,
	linux-gpio@vger.kernel.org, kernel-janitors

On Wed, Feb 15, 2017 at 12:02 AM, Dan Carpenter
<dan.carpenter@oracle.com> wrote:

> copy_from_user() returns the number of bytes remaining to be copied but
> we want to return negative error codes on failue.
>
> Fixes: 9202ba2397d1 ("gpio: mockup: implement event injecting over debugfs")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Patch applied for fixes.

Yours,
Linus Walleij

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

end of thread, other threads:[~2017-02-23 13:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-14 23:02 [patch] gpio: mockup: return -EFAULT if copy_from_user() fails Dan Carpenter
2017-02-15  9:16 ` Bartosz Golaszewski
2017-02-23 13:52 ` Linus Walleij

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).