[PATCH 1/1] pinctrl: mediatek: correct error handling

Andy Shevchenko andy.shevchenko at gmail.com
Sun Dec 27 17:12:29 CET 2020


On Sunday, December 27, 2020, Heinrich Schuchardt <xypron.glpk at 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 at 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


More information about the U-Boot mailing list