Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Dan Carpenter and committed by
Linus Walleij
fa6256db 9ce9f799

+3 -4
+3 -4
drivers/gpio/gpio-mockup.c
··· 197 197 struct seq_file *sfile; 198 198 struct gpio_desc *desc; 199 199 struct gpio_chip *gc; 200 - int status, val; 200 + int val; 201 201 char buf; 202 202 203 203 sfile = file->private_data; ··· 206 206 chip = priv->chip; 207 207 gc = &chip->gc; 208 208 209 - status = copy_from_user(&buf, usr_buf, 1); 210 - if (status) 211 - return status; 209 + if (copy_from_user(&buf, usr_buf, 1)) 210 + return -EFAULT; 212 211 213 212 if (buf == '0') 214 213 val = 0;