Skip to contentSkip to conversation

gpio: sysfs: fix inverted pointer logic

PATCH In review Bartosz Golaszewski 2 participants 4 messages Feb 14, 2024 – Feb 15, 2024 GPIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio: sysfs: fix inverted pointer logic

From: Bartosz Golaszewski <[email protected]>

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")
---
 drivers/gpio/gpiolib-sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpiolib-sysfs.c +1 -1
index 6285fa5afbb1..e4a6df2b317d 100644
@@ -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 */
Signature · 1 line
2.40.1
#1 lore raw

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

...

Quoted 1 line
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.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#2 lore raw
Quoted 12 lines · Andy Shevchenko

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

...

Quoted 1 line
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

#3 lore raw
In reply to Bartosz Golaszewski
Quoted 27 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

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")
---
 drivers/gpio/gpiolib-sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpiolib-sysfs.c +1 -2
index 6285fa5afbb1..e4a6df2b317d 100644
@@ -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 */
--
Quoted 2 lines

2.40.1

Patch applied.

Bart