[PATCH] usb: mtu3: Fix device_find_first_child() return value handling

Marek Vasut marex at denx.de
Sun Jul 16 17:53:46 CEST 2023


This function only ever returns 0, but may not assign the second
parameter. Check the second parameter instead.

Reported-by: Jonas Karlman <jonas at kwiboo.se>
Signed-off-by: Marek Vasut <marex at denx.de>
---
Cc: Chunfeng Yun <chunfeng.yun at mediatek.com>
Cc: GSS_MTK_Uboot_upstream <GSS_MTK_Uboot_upstream at mediatek.com>
Cc: Marek Vasut <marex at denx.de>
Cc: Ryder Lee <ryder.lee at mediatek.com>
Cc: Weijie Gao <weijie.gao at mediatek.com>
---
 drivers/usb/mtu3/mtu3_plat.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/mtu3/mtu3_plat.c b/drivers/usb/mtu3/mtu3_plat.c
index b1b22b9357c..7eb8360eada 100644
--- a/drivers/usb/mtu3/mtu3_plat.c
+++ b/drivers/usb/mtu3/mtu3_plat.c
@@ -161,10 +161,10 @@ static int get_ssusb_rscs(struct udevice *dev, struct ssusb_mtk *ssusb)
 		return -ENODEV;
 	}
 
-	ret = device_find_first_child(dev, &child);
-	if (ret || !child) {
-		dev_err(dev, "failed to get child %d!\n", ret);
-		return ret;
+	device_find_first_child(dev, &child);
+	if (!child) {
+		dev_err(dev, "failed to get child!\n");
+		return -ENODEV;
 	}
 
 	ssusb->mac_base = devfdt_remap_addr_name(child, "mac");
-- 
2.40.1



More information about the U-Boot mailing list