linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Alexandre Courbot <gnurou@gmail.com>,
	linux-gpio <linux-gpio@vger.kernel.org>,
	kernel-janitors@vger.kernel.org
Subject: Re: [patch] gpio: mockup: return -EFAULT if copy_from_user() fails
Date: Wed, 15 Feb 2017 10:16:21 +0100	[thread overview]
Message-ID: <CAMpxmJU16zrxT-RLPp_GPO_wtd-aqDtw=M0bSmEwpYT+0z-phA@mail.gmail.com> (raw)
In-Reply-To: <20170214230206.GA4048@mwanda>

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>

  reply	other threads:[~2017-02-15  9:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-14 23:02 [patch] gpio: mockup: return -EFAULT if copy_from_user() fails Dan Carpenter
2017-02-15  9:16 ` Bartosz Golaszewski [this message]
2017-02-23 13:52 ` Linus Walleij

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='CAMpxmJU16zrxT-RLPp_GPO_wtd-aqDtw=M0bSmEwpYT+0z-phA@mail.gmail.com' \
    --to=bgolaszewski@baylibre.com \
    --cc=bamvor.zhangjian@linaro.org \
    --cc=dan.carpenter@oracle.com \
    --cc=gnurou@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@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;
as well as URLs for NNTP newsgroup(s).