diff mbox series

usb: chipidea: add a check for the availability of next child

Message ID 20181226020134.71351-1-kjlu@umn.edu (mailing list archive)
State Superseded
Headers show
Series usb: chipidea: add a check for the availability of next child | expand

Commit Message

Kangjie Lu Dec. 26, 2018, 2:01 a.m. UTC
of_get_next_available_child returns NULL when no child nodes are found.
The fix checks its return value instead of assuming a child is found.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
 drivers/usb/chipidea/ci_hdrc_msm.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Peter Chen Dec. 26, 2018, 6:46 a.m. UTC | #1
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
>  drivers/usb/chipidea/ci_hdrc_msm.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/usb/chipidea/ci_hdrc_msm.c
> b/drivers/usb/chipidea/ci_hdrc_msm.c
> index 880009987460..7dc987b4036a 100644
> --- a/drivers/usb/chipidea/ci_hdrc_msm.c
> +++ b/drivers/usb/chipidea/ci_hdrc_msm.c
> @@ -250,6 +250,8 @@ static int ci_hdrc_msm_probe(struct platform_device *pdev)
>  	ulpi_node = of_get_child_by_name(pdev->dev.of_node, "ulpi");
>  	if (ulpi_node) {
>  		phy_node = of_get_next_available_child(ulpi_node, NULL);
> +		if (!phy_node)
> +			dev_err(&pdev->dev, "no child nodes found\n");
>  		ci->hsic = of_device_is_compatible(phy_node, "qcom,usb-hsic-phy");
>  		of_node_put(phy_node);
>  	}

With "ulpi" node, but phy node is not found, I assume the controller can't work properly, we may need to
return error value.  Add loic to confirm.

Peter
diff mbox series

Patch

diff --git a/drivers/usb/chipidea/ci_hdrc_msm.c b/drivers/usb/chipidea/ci_hdrc_msm.c
index 880009987460..7dc987b4036a 100644
--- a/drivers/usb/chipidea/ci_hdrc_msm.c
+++ b/drivers/usb/chipidea/ci_hdrc_msm.c
@@ -250,6 +250,8 @@  static int ci_hdrc_msm_probe(struct platform_device *pdev)
 	ulpi_node = of_get_child_by_name(pdev->dev.of_node, "ulpi");
 	if (ulpi_node) {
 		phy_node = of_get_next_available_child(ulpi_node, NULL);
+		if (!phy_node)
+			dev_err(&pdev->dev, "no child nodes found\n");
 		ci->hsic = of_device_is_compatible(phy_node, "qcom,usb-hsic-phy");
 		of_node_put(phy_node);
 	}