diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2017-02-14 18:02:06 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2017-03-06 08:35:21 -0500 |
commit | fa6256db033067b57318decdc1c583512a1f8f68 (patch) | |
tree | c0d0cbce48775859ff1800c2b0a3ca301e5eb13a | |
parent | 9ce9f7999741f342eeffd036ab09213a2fa93040 (diff) |
gpio: mockup: return -EFAULT if copy_from_user() fails
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>
Acked-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r-- | drivers/gpio/gpio-mockup.c | 7 |
1 files changed, 3 insertions, 4 deletions
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, | |||
197 | struct seq_file *sfile; | 197 | struct seq_file *sfile; |
198 | struct gpio_desc *desc; | 198 | struct gpio_desc *desc; |
199 | struct gpio_chip *gc; | 199 | struct gpio_chip *gc; |
200 | int status, val; | 200 | int val; |
201 | char buf; | 201 | char buf; |
202 | 202 | ||
203 | sfile = file->private_data; | 203 | sfile = file->private_data; |
@@ -206,9 +206,8 @@ static ssize_t gpio_mockup_event_write(struct file *file, | |||
206 | chip = priv->chip; | 206 | chip = priv->chip; |
207 | gc = &chip->gc; | 207 | gc = &chip->gc; |
208 | 208 | ||
209 | status = copy_from_user(&buf, usr_buf, 1); | 209 | if (copy_from_user(&buf, usr_buf, 1)) |
210 | if (status) | 210 | return -EFAULT; |
211 | return status; | ||
212 | 211 | ||
213 | if (buf == '0') | 212 | if (buf == '0') |
214 | val = 0; | 213 | val = 0; |