[PATCH v3 2/5] usb: dwc3-generic: Return early when there is no child node
Kever Yang
kever.yang at rock-chips.com
Wed Jul 26 11:23:20 CEST 2023
On 2023/7/17 06:35, Jonas Karlman wrote:
> 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 at kwiboo.se>
> Reviewed-by: Marek Vasut <marex at denx.de>
Reviewed-by: Kever Yang <kever.yang at rock-chips.com>
Thanks,
- Kever
> ---
> v3:
> - Collect r-b tag
> v2:
> - Update commit message
>
> drivers/usb/dwc3/dwc3-generic.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
> index 35e4b36a695e..4d5d500aefab 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);
More information about the U-Boot
mailing list