* [PATCH] ACPI / gpio: avoid warning for gpio hogging code
@ 2016-11-08 13:40 Arnd Bergmann
2016-11-08 14:12 ` Mika Westerberg
2016-11-09 8:44 ` Linus Walleij
0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2016-11-08 13:40 UTC (permalink / raw)
To: Linus Walleij
Cc: Arnd Bergmann, Alexandre Courbot, Mika Westerberg,
Rafael J. Wysocki, Dmitry Torokhov, Wei Yongjun,
Christophe Ricard, linux-gpio, linux-kernel
The newly added acpi_gpiochip_scan_gpios function produces a few harmless
warnings:
drivers/gpio/gpiolib-acpi.c: In function ‘acpi_gpiochip_add’:
drivers/gpio/gpiolib-acpi.c:925:7: error: ‘dflags’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
drivers/gpio/gpiolib-acpi.c:925:9: error: ‘lflags’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
The problem is that he compiler cannot know that a negative return value
from fwnode_property_read_u32_array() or acpi_gpiochip_pin_to_gpio_offset()
implies that the IS_ERR(gpio_desc) is true, as the value could in theory
be below -MAX_ERRNO.
The function already initializes its output values to zero, and moving
that intialization a little higher up ensures that we can never have
uninitialized data in the caller.
Fixes: c80f1ba75df2 ("ACPI / gpio: Add hogging support")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/gpio/gpiolib-acpi.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index 265e0fad518e..a3faefa44f68 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -869,6 +869,10 @@ static struct gpio_desc *acpi_gpiochip_parse_own_gpio(
u32 gpios[2];
int ret;
+ *lflags = 0;
+ *dflags = 0;
+ *name = NULL;
+
ret = fwnode_property_read_u32_array(fwnode, "gpios", gpios,
ARRAY_SIZE(gpios));
if (ret < 0)
@@ -882,10 +886,6 @@ static struct gpio_desc *acpi_gpiochip_parse_own_gpio(
if (IS_ERR(desc))
return desc;
- *lflags = 0;
- *dflags = 0;
- *name = NULL;
-
if (gpios[1])
*lflags |= GPIO_ACTIVE_LOW;
--
2.9.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ACPI / gpio: avoid warning for gpio hogging code
2016-11-08 13:40 [PATCH] ACPI / gpio: avoid warning for gpio hogging code Arnd Bergmann
@ 2016-11-08 14:12 ` Mika Westerberg
2016-11-09 8:44 ` Linus Walleij
1 sibling, 0 replies; 3+ messages in thread
From: Mika Westerberg @ 2016-11-08 14:12 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Linus Walleij, Alexandre Courbot, Rafael J. Wysocki,
Dmitry Torokhov, Wei Yongjun, Christophe Ricard, linux-gpio,
linux-kernel
On Tue, Nov 08, 2016 at 02:40:06PM +0100, Arnd Bergmann wrote:
> The newly added acpi_gpiochip_scan_gpios function produces a few harmless
> warnings:
>
> drivers/gpio/gpiolib-acpi.c: In function ‘acpi_gpiochip_add’:
> drivers/gpio/gpiolib-acpi.c:925:7: error: ‘dflags’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> drivers/gpio/gpiolib-acpi.c:925:9: error: ‘lflags’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>
> The problem is that he compiler cannot know that a negative return value
> from fwnode_property_read_u32_array() or acpi_gpiochip_pin_to_gpio_offset()
> implies that the IS_ERR(gpio_desc) is true, as the value could in theory
> be below -MAX_ERRNO.
>
> The function already initializes its output values to zero, and moving
> that intialization a little higher up ensures that we can never have
> uninitialized data in the caller.
>
> Fixes: c80f1ba75df2 ("ACPI / gpio: Add hogging support")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ACPI / gpio: avoid warning for gpio hogging code
2016-11-08 13:40 [PATCH] ACPI / gpio: avoid warning for gpio hogging code Arnd Bergmann
2016-11-08 14:12 ` Mika Westerberg
@ 2016-11-09 8:44 ` Linus Walleij
1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2016-11-09 8:44 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Alexandre Courbot, Mika Westerberg, Rafael J. Wysocki,
Dmitry Torokhov, Wei Yongjun, Christophe Ricard, linux-gpio,
linux-kernel
On Tue, Nov 8, 2016 at 2:40 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> The newly added acpi_gpiochip_scan_gpios function produces a few harmless
> warnings:
>
> drivers/gpio/gpiolib-acpi.c: In function ‘acpi_gpiochip_add’:
> drivers/gpio/gpiolib-acpi.c:925:7: error: ‘dflags’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> drivers/gpio/gpiolib-acpi.c:925:9: error: ‘lflags’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>
> The problem is that he compiler cannot know that a negative return value
> from fwnode_property_read_u32_array() or acpi_gpiochip_pin_to_gpio_offset()
> implies that the IS_ERR(gpio_desc) is true, as the value could in theory
> be below -MAX_ERRNO.
>
> The function already initializes its output values to zero, and moving
> that intialization a little higher up ensures that we can never have
> uninitialized data in the caller.
>
> Fixes: c80f1ba75df2 ("ACPI / gpio: Add hogging support")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Patch applied with Mika's ACK.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-11-09 8:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-08 13:40 [PATCH] ACPI / gpio: avoid warning for gpio hogging code Arnd Bergmann
2016-11-08 14:12 ` Mika Westerberg
2016-11-09 8:44 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).