[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMRc=MdL2rnCG1ix_iTKAZ5+Oa9bC7P5BmKzYCZtQuyrP2DZGA@mail.gmail.com>
Date: Wed, 23 Oct 2024 09:30:21 +0200
From: Bartosz Golaszewski <brgl@...ev.pl>
To: Suraj Sonawane <surajsonawane0215@...il.com>
Cc: linus.walleij@...aro.org, linux-gpio@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] gpio: fix uninit-value in swnode_find_gpio
On Tue, Oct 22, 2024 at 9:54 PM Suraj Sonawane
<surajsonawane0215@...il.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@...il.com>
Please add a Fixes tag too.
Bart
Powered by blists - more mailing lists