]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
usb: dwc3-generic: Return early when there is no child node
authorJonas Karlman <jonas@kwiboo.se>
Sun, 30 Jul 2023 22:59:55 +0000 (22:59 +0000)
committerKever Yang <kever.yang@rock-chips.com>
Mon, 31 Jul 2023 06:40:38 +0000 (14:40 +0800)
The current error check for device_find_first_child is not working as
expected, the documentation for device_find_first_child mention:

  @devp: Returns first child device, or NULL if none
  Return: 0

Change to return early when there is no child node to avoid any possible
null pointer dereference.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Reviewed-by: Marek Vasut <marex@denx.de>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
drivers/usb/dwc3/dwc3-generic.c

index 35e4b36a695e44e7867dd930d919a9d5d3a78bb3..4d5d500aefabc17e15144bce5a69def3ad051615 100644 (file)
@@ -558,9 +558,9 @@ int dwc3_glue_probe(struct udevice *dev)
                        return ret;
        }
 
-       ret = device_find_first_child(dev, &child);
-       if (ret)
-               return ret;
+       device_find_first_child(dev, &child);
+       if (!child)
+               return 0;
 
        if (glue->clks.count == 0) {
                ret = dwc3_glue_clk_init(child, glue);