* [PATCH] gpio: fix uninit-value in swnode_find_gpio
@ 2024-10-22 19:46 Suraj Sonawane
2024-10-22 19:54 ` [PATCH v2] " Suraj Sonawane
2024-10-26 9:06 ` [PATCH v3] " Suraj Sonawane
0 siblings, 2 replies; 6+ messages in thread
From: Suraj Sonawane @ 2024-10-22 19:46 UTC (permalink / raw)
To: linus.walleij; +Cc: brgl, linux-gpio, linux-kernel, Suraj Sonawane
Fix an issue detected by the Smatch tool:\
drivers/gpio/gpiolib-swnode.c:78 swnode_find_gpio() error:
uninitialized symbol 'ret'.
The issue occurs because the 'ret' variable may be used without
initialization if the for_each_gpio_property_name loop does not run.
This could lead to returning an undefined value, causing unpredictable
behavior.
Initialize 'ret' to -EINVAL before the loop to ensure the function
returns an error code if no properties are parsed, maintaining proper
error handling.
Signed-off-by: Suraj Sonawane <surajsonawane0215@gmail.com>
---
drivers/gpio/gpiolib-swnode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpio/gpiolib-swnode.c b/drivers/gpio/gpiolib-swnode.c
index 2b2dd7e92..51d2475c0 100644
--- a/drivers/gpio/gpiolib-swnode.c
+++ b/drivers/gpio/gpiolib-swnode.c
@@ -64,7 +64,7 @@ struct gpio_desc *swnode_find_gpio(struct fwnode_handle *fwnode,
struct fwnode_reference_args args;
struct gpio_desc *desc;
char propname[32]; /* 32 is max size of property name */
- int ret;
+ int ret = 0;
swnode = to_software_node(fwnode);
if (!swnode)
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2] gpio: fix uninit-value in swnode_find_gpio
2024-10-22 19:46 [PATCH] gpio: fix uninit-value in swnode_find_gpio Suraj Sonawane
@ 2024-10-22 19:54 ` Suraj Sonawane
2024-10-23 7:30 ` Bartosz Golaszewski
2024-10-26 9:06 ` [PATCH v3] " Suraj Sonawane
1 sibling, 1 reply; 6+ messages in thread
From: Suraj Sonawane @ 2024-10-22 19:54 UTC (permalink / raw)
To: surajsonawane0215; +Cc: brgl, linus.walleij, linux-gpio, linux-kernel
Fix an issue detected by the Smatch tool:
drivers/gpio/gpiolib-swnode.c:78 swnode_find_gpio() error:
uninitialized symbol 'ret'.
The issue occurs because the 'ret' variable may be used without
initialization if the for_each_gpio_property_name loop does not run.
This could lead to returning an undefined value, causing unpredictable
behavior.
Initialize 'ret' to 0 before the loop to ensure the function
returns an error code if no properties are parsed, maintaining proper
error handling.
Signed-off-by: Suraj Sonawane <surajsonawane0215@gmail.com>
---
V1: https://lore.kernel.org/lkml/20241022194624.34223-1-surajsonawane0215@gmail.com/T/#u
V2: Improved commit message.
drivers/gpio/gpiolib-swnode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpio/gpiolib-swnode.c b/drivers/gpio/gpiolib-swnode.c
index 2b2dd7e92..51d2475c0 100644
--- a/drivers/gpio/gpiolib-swnode.c
+++ b/drivers/gpio/gpiolib-swnode.c
@@ -64,7 +64,7 @@ struct gpio_desc *swnode_find_gpio(struct fwnode_handle *fwnode,
struct fwnode_reference_args args;
struct gpio_desc *desc;
char propname[32]; /* 32 is max size of property name */
- int ret;
+ int ret = 0;
swnode = to_software_node(fwnode);
if (!swnode)
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] gpio: fix uninit-value in swnode_find_gpio
2024-10-22 19:54 ` [PATCH v2] " Suraj Sonawane
@ 2024-10-23 7:30 ` Bartosz Golaszewski
0 siblings, 0 replies; 6+ messages in thread
From: Bartosz Golaszewski @ 2024-10-23 7:30 UTC (permalink / raw)
To: Suraj Sonawane; +Cc: linus.walleij, linux-gpio, linux-kernel
On Tue, Oct 22, 2024 at 9:54 PM Suraj Sonawane
<surajsonawane0215@gmail.com> wrote:
>
> Fix an issue detected by the Smatch tool:
>
> drivers/gpio/gpiolib-swnode.c:78 swnode_find_gpio() error:
> uninitialized symbol 'ret'.
>
> The issue occurs because the 'ret' variable may be used without
> initialization if the for_each_gpio_property_name loop does not run.
> This could lead to returning an undefined value, causing unpredictable
> behavior.
>
> Initialize 'ret' to 0 before the loop to ensure the function
> returns an error code if no properties are parsed, maintaining proper
> error handling.
>
> Signed-off-by: Suraj Sonawane <surajsonawane0215@gmail.com>
Please add a Fixes tag too.
Bart
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3] gpio: fix uninit-value in swnode_find_gpio
2024-10-22 19:46 [PATCH] gpio: fix uninit-value in swnode_find_gpio Suraj Sonawane
2024-10-22 19:54 ` [PATCH v2] " Suraj Sonawane
@ 2024-10-26 9:06 ` Suraj Sonawane
2024-10-31 12:39 ` Bartosz Golaszewski
1 sibling, 1 reply; 6+ messages in thread
From: Suraj Sonawane @ 2024-10-26 9:06 UTC (permalink / raw)
To: surajsonawane0215; +Cc: brgl, linus.walleij, linux-gpio, linux-kernel
Fix an issue detected by the Smatch tool:
drivers/gpio/gpiolib-swnode.c:78 swnode_find_gpio() error:
uninitialized symbol 'ret'.
The issue occurs because the 'ret' variable may be used without
initialization if the for_each_gpio_property_name loop does not run.
This could lead to returning an undefined value, causing unpredictable
behavior.
Initialize 'ret' to 0 before the loop to ensure the function
returns an error code if no properties are parsed, maintaining proper
error handling.
Fixes: 9e4c6c1ad ("Merge tag 'io_uring-6.12-20241011' of git://git.kernel.dk/linux")
Signed-off-by: Suraj Sonawane <surajsonawane0215@gmail.com>
---
V1: https://lore.kernel.org/lkml/20241022194624.34223-1-surajsonawane0215@gmail.com/T/#u
V2: Improved commit message.
V3: Add fixes tag.
drivers/gpio/gpiolib-swnode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpio/gpiolib-swnode.c b/drivers/gpio/gpiolib-swnode.c
index 2b2dd7e92..51d2475c0 100644
--- a/drivers/gpio/gpiolib-swnode.c
+++ b/drivers/gpio/gpiolib-swnode.c
@@ -64,7 +64,7 @@ struct gpio_desc *swnode_find_gpio(struct fwnode_handle *fwnode,
struct fwnode_reference_args args;
struct gpio_desc *desc;
char propname[32]; /* 32 is max size of property name */
- int ret;
+ int ret = 0;
swnode = to_software_node(fwnode);
if (!swnode)
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v3] gpio: fix uninit-value in swnode_find_gpio
2024-10-26 9:06 ` [PATCH v3] " Suraj Sonawane
@ 2024-10-31 12:39 ` Bartosz Golaszewski
2024-11-01 10:37 ` Suraj Sonawane
0 siblings, 1 reply; 6+ messages in thread
From: Bartosz Golaszewski @ 2024-10-31 12:39 UTC (permalink / raw)
To: Suraj Sonawane
Cc: Bartosz Golaszewski, brgl, linus.walleij, linux-gpio,
linux-kernel
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
On Sat, 26 Oct 2024 14:36:42 +0530, Suraj Sonawane wrote:
> Fix an issue detected by the Smatch tool:
>
> drivers/gpio/gpiolib-swnode.c:78 swnode_find_gpio() error:
> uninitialized symbol 'ret'.
>
> The issue occurs because the 'ret' variable may be used without
> initialization if the for_each_gpio_property_name loop does not run.
> This could lead to returning an undefined value, causing unpredictable
> behavior.
>
> [...]
Applied, thanks!
[1/1] gpio: fix uninit-value in swnode_find_gpio
commit: a14968aea637bbe38a99e6089944e4ad8e6c49e5
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] gpio: fix uninit-value in swnode_find_gpio
2024-10-31 12:39 ` Bartosz Golaszewski
@ 2024-11-01 10:37 ` Suraj Sonawane
0 siblings, 0 replies; 6+ messages in thread
From: Suraj Sonawane @ 2024-11-01 10:37 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Bartosz Golaszewski, linus.walleij, linux-gpio, linux-kernel
On 31/10/24 18:09, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
>
> On Sat, 26 Oct 2024 14:36:42 +0530, Suraj Sonawane wrote:
>> Fix an issue detected by the Smatch tool:
>>
>> drivers/gpio/gpiolib-swnode.c:78 swnode_find_gpio() error:
>> uninitialized symbol 'ret'.
>>
>> The issue occurs because the 'ret' variable may be used without
>> initialization if the for_each_gpio_property_name loop does not run.
>> This could lead to returning an undefined value, causing unpredictable
>> behavior.
>>
>> [...]
>
> Applied, thanks!
>
> [1/1] gpio: fix uninit-value in swnode_find_gpio
> commit: a14968aea637bbe38a99e6089944e4ad8e6c49e5
>
> Best regards,
Thank you for applying this patch.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-11-01 10:38 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-22 19:46 [PATCH] gpio: fix uninit-value in swnode_find_gpio Suraj Sonawane
2024-10-22 19:54 ` [PATCH v2] " Suraj Sonawane
2024-10-23 7:30 ` Bartosz Golaszewski
2024-10-26 9:06 ` [PATCH v3] " Suraj Sonawane
2024-10-31 12:39 ` Bartosz Golaszewski
2024-11-01 10:37 ` Suraj Sonawane
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox