Skip to content

Commit a14968a

Browse files
SurajSonawane2415Bartosz Golaszewski
authored andcommitted
gpio: fix uninit-value in swnode_find_gpio
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: 9e4c6c1 ("Merge tag 'io_uring-6.12-20241011' of git://git.kernel.dk/linux") Signed-off-by: Suraj Sonawane <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent 8198375 commit a14968a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/gpio/gpiolib-swnode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ struct gpio_desc *swnode_find_gpio(struct fwnode_handle *fwnode,
6464
struct fwnode_reference_args args;
6565
struct gpio_desc *desc;
6666
char propname[32]; /* 32 is max size of property name */
67-
int ret;
67+
int ret = 0;
6868

6969
swnode = to_software_node(fwnode);
7070
if (!swnode)

0 commit comments

Comments
 (0)