Linux GPIO subsystem development
 help / color / mirror / Atom feed
* [PATCH] gpio: sysfs: fix inverted pointer logic
@ 2024-02-14  8:52 Bartosz Golaszewski
  2024-02-14 12:52 ` Andy Shevchenko
  2024-02-15  7:42 ` Bartosz Golaszewski
  0 siblings, 2 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2024-02-14  8:52 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Andy Shevchenko,
	Dan Carpenter
  Cc: linux-gpio, linux-kernel, Bartosz Golaszewski

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

The logic is inverted, we want to return if the chip *IS* NULL.

Fixes: d83cee3d2bb1 ("gpio: protect the pointer to gpio_chip in gpio_device with SRCU")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/linux-gpio/15671341-0b29-40e0-b487-0a4cdc414d8e@moroto.mountain/
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 drivers/gpio/gpiolib-sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c
index 6285fa5afbb1..e4a6df2b317d 100644
--- a/drivers/gpio/gpiolib-sysfs.c
+++ b/drivers/gpio/gpiolib-sysfs.c
@@ -801,7 +801,7 @@ void gpiochip_sysfs_unregister(struct gpio_device *gdev)
 	guard(srcu)(&gdev->srcu);
 
 	chip = rcu_dereference(gdev->chip);
-	if (chip)
+	if (!chip)
 		return;
 
 	/* unregister gpiod class devices owned by sysfs */
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] gpio: sysfs: fix inverted pointer logic
  2024-02-14  8:52 [PATCH] gpio: sysfs: fix inverted pointer logic Bartosz Golaszewski
@ 2024-02-14 12:52 ` Andy Shevchenko
  2024-02-14 13:01   ` Bartosz Golaszewski
  2024-02-15  7:42 ` Bartosz Golaszewski
  1 sibling, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2024-02-14 12:52 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Linus Walleij, Dan Carpenter, linux-gpio, linux-kernel,
	Bartosz Golaszewski

On Wed, Feb 14, 2024 at 09:52:48AM +0100, Bartosz Golaszewski wrote:

...

> Fixes: d83cee3d2bb1 ("gpio: protect the pointer to gpio_chip in gpio_device with SRCU")

I'm wondering if instead tons of fixes you can just fold the patches and rebase your tree.

Yes, we still have time to let it soak in Linux Next, so Torvalds won't complain.
It will be much less burden to anybody who wants to backport this nice work.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] gpio: sysfs: fix inverted pointer logic
  2024-02-14 12:52 ` Andy Shevchenko
@ 2024-02-14 13:01   ` Bartosz Golaszewski
  0 siblings, 0 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2024-02-14 13:01 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Linus Walleij, Dan Carpenter, linux-gpio, linux-kernel,
	Bartosz Golaszewski

On Wed, Feb 14, 2024 at 1:52 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Wed, Feb 14, 2024 at 09:52:48AM +0100, Bartosz Golaszewski wrote:
>
> ...
>
> > Fixes: d83cee3d2bb1 ("gpio: protect the pointer to gpio_chip in gpio_device with SRCU")
>
> I'm wondering if instead tons of fixes you can just fold the patches and rebase your tree.
>
> Yes, we still have time to let it soak in Linux Next, so Torvalds won't complain.
> It will be much less burden to anybody who wants to backport this nice work.
>

No, I don't think so. Rebasing is reserved for really special cases
when nothing else can be done. Fixes like that should be expected for
a big rework like this. This is honestly a strange idea.

And I don't think anyone should backport this work. It's simply way
too big and touches too many places.

Bart

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] gpio: sysfs: fix inverted pointer logic
  2024-02-14  8:52 [PATCH] gpio: sysfs: fix inverted pointer logic Bartosz Golaszewski
  2024-02-14 12:52 ` Andy Shevchenko
@ 2024-02-15  7:42 ` Bartosz Golaszewski
  1 sibling, 0 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2024-02-15  7:42 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Andy Shevchenko,
	Dan Carpenter
  Cc: linux-gpio, linux-kernel, Bartosz Golaszewski

On Wed, Feb 14, 2024 at 9:52 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
>
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> The logic is inverted, we want to return if the chip *IS* NULL.
>
> Fixes: d83cee3d2bb1 ("gpio: protect the pointer to gpio_chip in gpio_device with SRCU")
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Closes: https://lore.kernel.org/linux-gpio/15671341-0b29-40e0-b487-0a4cdc414d8e@moroto.mountain/
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> ---
>  drivers/gpio/gpiolib-sysfs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c
> index 6285fa5afbb1..e4a6df2b317d 100644
> --- a/drivers/gpio/gpiolib-sysfs.c
> +++ b/drivers/gpio/gpiolib-sysfs.c
> @@ -801,7 +801,7 @@ void gpiochip_sysfs_unregister(struct gpio_device *gdev)
>         guard(srcu)(&gdev->srcu);
>
>         chip = rcu_dereference(gdev->chip);
> -       if (chip)
> +       if (!chip)
>                 return;
>
>         /* unregister gpiod class devices owned by sysfs */
> --
> 2.40.1
>

Patch applied.

Bart

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-02-15  7:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-14  8:52 [PATCH] gpio: sysfs: fix inverted pointer logic Bartosz Golaszewski
2024-02-14 12:52 ` Andy Shevchenko
2024-02-14 13:01   ` Bartosz Golaszewski
2024-02-15  7:42 ` Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox