Re: [PATCH v2] gpio: fix uninit-value in swnode_find_gpio

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Oct 22, 2024 at 9:54 PM Suraj Sonawane
<surajsonawane0215@xxxxxxxxx> 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@xxxxxxxxx>

Please add a Fixes tag too.

Bart





[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux