Message ID | d1ec9f4cb6dd9afcfbeecfa717e863d75e18133b.1617017060.git.matti.vaittinen@fi.rohmeurope.com |
---|---|
State | Accepted |
Commit | 23cf00ddd2e1aacf1873e43f5e0c519c120daf7a |
Headers | show |
Series | [1/2] gpio: sysfs: Obey valid_mask | expand |
On Mon, Mar 29, 2021 at 1:41 PM Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com> wrote: > > Do not allow exporting GPIOs which are set invalid > by the driver's valid mask. > > Fixes: 726cb3ba49692bdae6caff457755e7cdb432efa4 > > Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com> > --- Applied, thanks! Bart
On Wed, Mar 31, 2021 at 10:58 AM Bartosz Golaszewski <bgolaszewski@baylibre.com> wrote: > > On Mon, Mar 29, 2021 at 1:41 PM Matti Vaittinen > <matti.vaittinen@fi.rohmeurope.com> wrote: > > > > Do not allow exporting GPIOs which are set invalid > > by the driver's valid mask. > > > > Fixes: 726cb3ba49692bdae6caff457755e7cdb432efa4 I have just noticed that this is invalid format for the Fixes tag (luckily, haha, due to a blank line it's not recognized as a tag!). Matti, I highly recommend to add in your .gitconfig file an alias: one = show -s --pretty='format:%h (\"%s\")' Bart, there are real Fixes tag issues from another series. I will comment there as well to let an author know. -- With Best Regards, Andy Shevchenko
On Wed, Mar 31, 2021 at 2:25 PM Andy Shevchenko <andy.shevchenko@gmail.com> wrote: > > On Wed, Mar 31, 2021 at 10:58 AM Bartosz Golaszewski > <bgolaszewski@baylibre.com> wrote: > > > > On Mon, Mar 29, 2021 at 1:41 PM Matti Vaittinen > > <matti.vaittinen@fi.rohmeurope.com> wrote: > > > > > > Do not allow exporting GPIOs which are set invalid > > > by the driver's valid mask. > > > > > > Fixes: 726cb3ba49692bdae6caff457755e7cdb432efa4 > > I have just noticed that this is invalid format for the Fixes tag > (luckily, haha, due to a blank line it's not recognized as a tag!). > > Matti, I highly recommend to add in your .gitconfig file an alias: > one = show -s --pretty='format:%h (\"%s\")' > > Bart, there are real Fixes tag issues from another series. I will > comment there as well to let an author know. > > -- Eek, sorry I should have looked more carefully. I'll fix it in my tree. Bartosz
On Wed, 2021-03-31 at 20:29 +0200, Bartosz Golaszewski wrote: > On Wed, Mar 31, 2021 at 2:25 PM Andy Shevchenko > <andy.shevchenko@gmail.com> wrote: > > On Wed, Mar 31, 2021 at 10:58 AM Bartosz Golaszewski > > <bgolaszewski@baylibre.com> wrote: > > > On Mon, Mar 29, 2021 at 1:41 PM Matti Vaittinen > > > <matti.vaittinen@fi.rohmeurope.com> wrote: > > > > Do not allow exporting GPIOs which are set invalid > > > > by the driver's valid mask. > > > > > > > > Fixes: 726cb3ba49692bdae6caff457755e7cdb432efa4 > > > > I have just noticed that this is invalid format for the Fixes tag > > (luckily, haha, due to a blank line it's not recognized as a tag!). > > > > Matti, I highly recommend to add in your .gitconfig file an alias: > > one = show -s --pretty='format:%h (\"%s\")' > > > > Bart, there are real Fixes tag issues from another series. I will > > comment there as well to let an author know. > > > > -- > > Eek, sorry I should have looked more carefully. I'll fix it in my > tree. Thanks for fixing this Bartosz. Andy - well spotted. And the alias you pointed is something I've missed :) Sorry for the trouble! I should have used the correct tag format. Thanks again! Best Regards Matti Vaittinen
diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c index 26c5466b8179..ae49bb23c6ed 100644 --- a/drivers/gpio/gpiolib-sysfs.c +++ b/drivers/gpio/gpiolib-sysfs.c @@ -458,6 +458,8 @@ static ssize_t export_store(struct class *class, long gpio; struct gpio_desc *desc; int status; + struct gpio_chip *gc; + int offset; status = kstrtol(buf, 0, &gpio); if (status < 0) @@ -469,6 +471,12 @@ static ssize_t export_store(struct class *class, pr_warn("%s: invalid GPIO %ld\n", __func__, gpio); return -EINVAL; } + gc = desc->gdev->chip; + offset = gpio_chip_hwgpio(desc); + if (!gpiochip_line_is_valid(gc, offset)) { + pr_warn("%s: GPIO %ld masked\n", __func__, gpio); + return -EINVAL; + } /* No extra locking here; FLAG_SYSFS just signifies that the * request and export were done by on behalf of userspace, so
Do not allow exporting GPIOs which are set invalid by the driver's valid mask. Fixes: 726cb3ba49692bdae6caff457755e7cdb432efa4 Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com> --- drivers/gpio/gpiolib-sysfs.c | 8 ++++++++ 1 file changed, 8 insertions(+)