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

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 --- v2: move the assigment to the certain code-path (Andy) --- drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c index 6553dde45c..4dd3f73ead 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c @@ -615,6 +615,7 @@ static int mtk_gpiochip_register(struct udevice *parent) if (!drv) return -ENOENT;
+ ret = -ENOENT; dev_for_each_subnode(node, parent) if (ofnode_read_bool(node, "gpio-controller")) { ret = 0; -- 2.29.2

On Sun, 2020-12-27 at 21:18 +0100, Heinrich Schuchardt 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
v2: move the assigment to the certain code-path (Andy)
drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c index 6553dde45c..4dd3f73ead 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c @@ -615,6 +615,7 @@ static int mtk_gpiochip_register(struct udevice *parent) if (!drv) return -ENOENT;
- ret = -ENOENT; dev_for_each_subnode(node, parent) if (ofnode_read_bool(node, "gpio-controller")) { ret = 0;
--
Acked-by: Chunfeng Yun chunfeng.yun@mediatek.com
Thanks
2.29.2

On Sun, Dec 27, 2020 at 09:18:26PM +0100, Heinrich Schuchardt 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 Acked-by: Chunfeng Yun chunfeng.yun@mediatek.com
Applied to u-boot/master, thanks!
participants (3)
-
Chunfeng Yun
-
Heinrich Schuchardt
-
Tom Rini