Skip to contentSkip to conversation

pinctrl: mediatek: correct error handling

PATCH New Heinrich Schuchardt 3 participants 3 messages Dec 27, 2020 – Jan 19, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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
index 6553dde45c..4dd3f73ead 100644
@@ -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

#1 lore raw

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.

---
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
index 6553dde45c..4dd3f73ead 100644

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

#2 lore raw

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

In reply to Heinrich Schuchardt
Quoted 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.

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>