gpiolib: Fix using uninitialized lookup-flags on ACPI platforms
Subsystems (3)
PATCH 1/1 gpiolib: Fix using uninitialized lookup-flags on ACPI platforms
Commit 8eb1f71e7acc ("gpiolib: consolidate GPIO lookups") refactors fwnode_get_named_gpiod() and gpiod_get_index() into a unified gpiod_find_and_request() helper.
The old functions both initialized their local lookupflags variable to GPIO_LOOKUP_FLAGS_DEFAULT, but the new code leaves it uninitialized.
This is a problem for at least ACPI platforms, where acpi_find_gpio() only does a bunch of *lookupflags |= GPIO_* statements and thus relies on the variable being initialized.
The variable not being initialized leads to:
1. Potentially the wrong flags getting used
2. The check for conflicting lookup flags in gpiod_configure_flags():
"multiple pull-up, pull-down or pull-disable enabled, invalid config" sometimes triggering, making the GPIO unavailable
Restore the initialization of lookupflags to GPIO_LOOKUP_FLAGS_DEFAULT to fix this.
---
Note I'm not working and not reading work email until Monday January 9th. I hit this while doing some hobby stuff and I decided to send this out right away to avoid others potentially wasting time debugging this, but I will not see any replies until Monday January 9th.
--- drivers/gpio/gpiolib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpiolib.c +1 -1
@@ -3905,8 +3905,8 @@ static struct gpio_desc *gpiod_find_and_request(struct device *consumer,const char *label, bool platform_lookup_allowed) { + unsigned long lookupflags = GPIO_LOOKUP_FLAGS_DEFAULT;struct gpio_desc *desc =ERR_PTR (-ENOENT ); -unsigned long lookupflags;int ret;if (!IS_ERR_OR_NULL (fwnode))
Signature · 1 line
2.38.1
Bartosz Golaszewski
AppliedQuoted 48 lines · Hans de Goede
Commit
8eb1f71e7acc("gpiolib: consolidate GPIO lookups") refactorsfwnode_get_named_gpiod()andgpiod_get_index()into a unifiedgpiod_find_and_request()helper.The old functions both initialized their local lookupflags variable to
GPIO_LOOKUP_FLAGS_DEFAULT, but the new code leaves it uninitialized.This is a problem for at least ACPI platforms, where
acpi_find_gpio()only does a bunch of *lookupflags |= GPIO_* statements and thus relies on the variable being initialized.The variable not being initialized leads to:
1. Potentially the wrong flags getting used
2. The check for conflicting lookup flags ingpiod_configure_flags():
"multiple pull-up, pull-down or pull-disable enabled, invalid config" sometimes triggering, making the GPIO unavailableRestore the initialization of lookupflags to
GPIO_LOOKUP_FLAGS_DEFAULTto fix this.Fixes 8eb1f71e7acc ("gpiolib: consolidate GPIO lookups")Signed-off-by Hans de Goede <[email protected]>---
Note I'm not working and not reading work email until Monday January 9th. I hit this while doing some hobby stuff and I decided to send this out right away to avoid others potentially wasting time debugging this, but I will not see any replies until Monday January 9th.--- drivers/gpio/gpiolib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpio/gpiolib.c +1
-2@@ -3905,8 +3905,8 @@ static struct gpio_desc *gpiod_find_and_request(struct device *consumer,const char *label, bool platform_lookup_allowed) { + unsigned long lookupflags = GPIO_LOOKUP_FLAGS_DEFAULT;struct gpio_desc *desc =ERR_PTR (-ENOENT ); -unsigned long lookupflags;int ret;if (!IS_ERR_OR_NULL (fwnode)) --
Quoted 2 lines
2.38.1
Queued for fixes, thanks!
Bart
Re: [PATCH 6.2 regression fix] gpiolib: Fix using uninitialized lookup-flags on ACPI platforms #forregzbot
In reply to Hans de Goede[Note: this mail contains only information for Linux kernel regression tracking. Mails like these contain '#forregzbot' in the subject to make then easy to spot and filter out. The author also tried to remove most or all individuals from the list of recipients to spare them the hassle.]
Quoted 21 lines · Hans de Goede
Commit
8eb1f71e7acc("gpiolib: consolidate GPIO lookups") refactorsfwnode_get_named_gpiod()andgpiod_get_index()into a unifiedgpiod_find_and_request()helper.The old functions both initialized their local lookupflags variable to
GPIO_LOOKUP_FLAGS_DEFAULT, but the new code leaves it uninitialized.This is a problem for at least ACPI platforms, where
acpi_find_gpio()only does a bunch of *lookupflags |= GPIO_* statements and thus relies on the variable being initialized.The variable not being initialized leads to:
1. Potentially the wrong flags getting used
2. The check for conflicting lookup flags ingpiod_configure_flags():
"multiple pull-up, pull-down or pull-disable enabled, invalid config" sometimes triggering, making the GPIO unavailableRestore the initialization of lookupflags to
GPIO_LOOKUP_FLAGS_DEFAULTto fix this.
Quoted 7 lines
Fixes 8eb1f71e7acc ("gpiolib: consolidate GPIO lookups")Signed-off-by Hans de Goede <[email protected]>---
Note I'm not working and not reading work email until Monday January 9th. I hit this while doing some hobby stuff and I decided to send this out right away to avoid others potentially wasting time debugging this, but I will not see any replies until Monday January 9th.
Thanks for the report. To be sure below issue doesn't fall through the cracks unnoticed, I'm adding it to regzbot, my Linux kernel regression tracking bot:
#regzbot ^introduced 8eb1f71e7acc
#regzbot title gpiolib: potentially the wrong flags getting used #regzbot fix: gpiolib: Fix using uninitialized lookup-flags on ACPI platforms
#regzbot ignore-activity
Ciao, Thorsten (wearing his 'the Linux kernel's regression tracker' hat)
P.S.: As the Linux kernel's regression tracker I deal with a lot of reports and sometimes miss something important when writing mails like this. If that's the case here, don't hesitate to tell me in a public reply, it's in everyone's interest to set the public record straight.