pinctrl: mediatek: correct error handling
Subsystems (3)
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.
---
v2:
move the assigment to the certain code-path (Andy)
--- drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 1 + 1 file changed, 1 insertion(+)
drivers/pinctrl/mediatek/pinctrl-mtk-common.c +1 -0
@@ -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
PATCH v2 1/1 pinctrl: mediatek: correct error handling
Quoted 18 lines · Heinrich Schuchardt
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 <[email protected]>---
v2:
move the assigment to the certain code-path (Andy)--- drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 1 + 1 file changed, 1 insertion(+)drivers/pinctrl/mediatek/pinctrl-mtk-common.c +0
-0
drivers/pinctrl/mediatek/pinctrl-mtk-common.c static int mtk_gpiochip_register(struct udevice *parent)
Quoted 8 lines
drivers/pinctrl/mediatek/pinctrl-mtk-common.c +1
-1@@ -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 ; --
Thanks
Quoted 2 lines
2.29.2
PATCH v2 1/1 pinctrl: mediatek: correct error handling
In reply to Heinrich SchuchardtQuoted 7 lines · Heinrich Schuchardt
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 <[email protected]>Acked-by Chunfeng Yun <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210119/c797462f/attachment.sig>