diff options
author | Jonas Karlman <jonas@kwiboo.se> | 2023-07-30 22:59:55 +0000 |
---|---|---|
committer | Kever Yang <kever.yang@rock-chips.com> | 2023-07-31 14:40:38 +0800 |
commit | 4412a2bf0b674d7438821531a0a19bbcd4b80eda (patch) | |
tree | 101a03e373518bac2acfae94392103aa05c00109 | |
parent | bec51f3fb316b5a5ccedd7deb2e58ae6d7443cfa (diff) | |
download | u-boot-4412a2bf0b674d7438821531a0a19bbcd4b80eda.tar.gz u-boot-4412a2bf0b674d7438821531a0a19bbcd4b80eda.tar.bz2 u-boot-4412a2bf0b674d7438821531a0a19bbcd4b80eda.zip |
usb: dwc3-generic: Return early when there is no child node
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>
-rw-r--r-- | drivers/usb/dwc3/dwc3-generic.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c index 35e4b36a69..4d5d500aef 100644 --- a/drivers/usb/dwc3/dwc3-generic.c +++ b/drivers/usb/dwc3/dwc3-generic.c @@ -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); |