Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1652983
| From | Bartosz Golaszewski <brgl@bgdev.pl> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v2 2/7] gpio: mockup: tweak gpio_mockup_event_write() |
| Date | 2017-05-30 11:10 +0200 |
| Message-ID | <tMLk5-5mP-13@gated-at.bofh.it> (permalink) |
| References | <tMLaq-54b-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Invert the logic of the irq_enabled check and only access the private
data after the input is sanitized.
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
---
drivers/gpio/gpio-mockup.c | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
index da76267..d78e8e0 100644
--- a/drivers/gpio/gpio-mockup.c
+++ b/drivers/gpio/gpio-mockup.c
@@ -210,24 +210,23 @@ static ssize_t gpio_mockup_event_write(struct file *file,
struct gpio_chip *gc;
int rv, val;
- sfile = file->private_data;
- priv = sfile->private;
- desc = priv->desc;
- chip = priv->chip;
- gc = &chip->gc;
-
rv = kstrtoint_from_user(usr_buf, size, 0, &val);
if (rv)
return rv;
if (val != 0 && val != 1)
return -EINVAL;
- if (!chip->lines[priv->offset].irq_enabled)
- return size;
+ sfile = file->private_data;
+ priv = sfile->private;
+ desc = priv->desc;
+ chip = priv->chip;
+ gc = &chip->gc;
- gpiod_set_value_cansleep(desc, val);
- priv->chip->irq_ctx.irq = gc->irq_base + priv->offset;
- irq_work_queue(&priv->chip->irq_ctx.work);
+ if (chip->lines[priv->offset].irq_enabled) {
+ gpiod_set_value_cansleep(desc, val);
+ priv->chip->irq_ctx.irq = gc->irq_base + priv->offset;
+ irq_work_queue(&priv->chip->irq_ctx.work);
+ }
return size;
}
--
2.9.3
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v2 0/7] gpio: mockup: updates for 4.13 Bartosz Golaszewski <brgl@bgdev.pl> - 2017-05-30 11:00 +0200 [PATCH v2 2/7] gpio: mockup: tweak gpio_mockup_event_write() Bartosz Golaszewski <brgl@bgdev.pl> - 2017-05-30 11:10 +0200 [PATCH v2 3/7] gpio: mockup: refuse to accept an odd number of GPIO ranges Bartosz Golaszewski <brgl@bgdev.pl> - 2017-05-30 11:10 +0200
csiph-web