mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 04:38:03 +00:00
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: 9e4c6c1ad
("Merge tag 'io_uring-6.12-20241011' of git://git.kernel.dk/linux")
Signed-off-by: Suraj Sonawane <surajsonawane0215@gmail.com>
Link: https://lore.kernel.org/r/20241026090642.28633-1-surajsonawane0215@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This commit is contained in:
parent
8198375843
commit
a14968aea6
@ -64,7 +64,7 @@ struct gpio_desc *swnode_find_gpio(struct fwnode_handle *fwnode,
|
|||||||
struct fwnode_reference_args args;
|
struct fwnode_reference_args args;
|
||||||
struct gpio_desc *desc;
|
struct gpio_desc *desc;
|
||||||
char propname[32]; /* 32 is max size of property name */
|
char propname[32]; /* 32 is max size of property name */
|
||||||
int ret;
|
int ret = 0;
|
||||||
|
|
||||||
swnode = to_software_node(fwnode);
|
swnode = to_software_node(fwnode);
|
||||||
if (!swnode)
|
if (!swnode)
|
||||||
|
Loading…
Reference in New Issue
Block a user