* [PATCH 1/1] pinctrl: mediatek: correct error handling
@ 2020-12-27 10:39 Heinrich Schuchardt
2020-12-27 16:12 ` Andy Shevchenko
0 siblings, 1 reply; 2+ messages in thread
From: Heinrich Schuchardt @ 2020-12-27 10:39 UTC (permalink / raw)
To: u-boot
If no GPIO controller is found, the return value should not depend on a
random value on the stack. Initialize variable ret.
The problem was indicated by cppcheck.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
index 6553dde45c..8b4e0e32c5 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
@@ -608,7 +608,7 @@ static int mtk_gpiochip_register(struct udevice *parent)
{
struct uclass_driver *drv;
struct udevice *dev;
- int ret;
+ int ret = -ENOENT;
ofnode node;
drv = lists_uclass_lookup(UCLASS_GPIO);
--
2.29.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 1/1] pinctrl: mediatek: correct error handling
2020-12-27 10:39 [PATCH 1/1] pinctrl: mediatek: correct error handling Heinrich Schuchardt
@ 2020-12-27 16:12 ` Andy Shevchenko
0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2020-12-27 16:12 UTC (permalink / raw)
To: u-boot
On Sunday, December 27, 2020, Heinrich Schuchardt <xypron.glpk@gmx.de>
wrote:
> If no GPIO controller is found, the return value should not depend on a
> random value on the stack. Initialize variable ret.
>
> The problem was indicated by cppcheck.
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
> drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
> b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
> index 6553dde45c..8b4e0e32c5 100644
> --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
> +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
> @@ -608,7 +608,7 @@ static int mtk_gpiochip_register(struct udevice
> *parent)
> {
> struct uclass_driver *drv;
> struct udevice *dev;
> - int ret;
> + int ret = -ENOENT;
It?s not the best approach. Consider to assign it in the certain code path.
> ofnode node;
>
> drv = lists_uclass_lookup(UCLASS_GPIO);
> --
> 2.29.2
>
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-12-27 16:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-27 10:39 [PATCH 1/1] pinctrl: mediatek: correct error handling Heinrich Schuchardt
2020-12-27 16:12 ` Andy Shevchenko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.