RE: [PATCH v2] usb: chipidea: add a check for the availability of next child

From: Peter Chen
Date: Wed Dec 26 2018 - 19:44:12 EST



> Signed-off-by: Kangjie Lu <kjlu@xxxxxxx>
> ---
> drivers/usb/chipidea/ci_hdrc_msm.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/usb/chipidea/ci_hdrc_msm.c
> b/drivers/usb/chipidea/ci_hdrc_msm.c
> index 880009987460..b7f7acef72d4 100644
> --- a/drivers/usb/chipidea/ci_hdrc_msm.c
> +++ b/drivers/usb/chipidea/ci_hdrc_msm.c
> @@ -250,6 +250,10 @@ 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");
> + return -ENODEV;
> + }

There are still two issues for this patch:
- It can't return -ENODEV directly, instead, it needs to goto err_mux
- Before goto err_mux, it needs to call of_node_put(ulpi_node);

Besides, for kernel code style, you may leave one blank line after if () {} statement.

Peter

> ci->hsic = of_device_is_compatible(phy_node, "qcom,usb-hsic-phy");
> of_node_put(phy_node);
> }
> --
> 2.17.2 (Apple Git-113)