Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 38213C0015E for ; Sun, 16 Jul 2023 16:01:12 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4B9AE86307; Sun, 16 Jul 2023 18:01:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1689523270; bh=LtYVyadH/FnXqUWMXy2/K0wmrTIf6a7Nlm2t6GoFhUM=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=KOhvpwYdguXrudENo4FWhxMFgNCajs6jCZtnONa0yNRzWpf7gFCZj/J5pYRfMG32L dY0NWefHDVZ//QZB4V8yTZVsZV62Gq/0UkqifGInUvW3W6anzTd4qztv80wWJaFyze OY7gYYktJWuQh5nxk0BsqaS0JjQa6ifOby+0T5wnKJn1g/otPburtEqPUh0ObayY4b 5//OVaFB2rtNBDh8Y0/x+QKhhA4GLezbZw5qlSHbMQsairhBkfGJUqNsnDlGzsspAN DHFBgnhZOnuf4XVpoq0vjY8c0p1PDguHoA4ZTXN5KjjTNJCylWSQybNwqrsm4OMkpe +O7hQBC3Pp0rw== Received: from [127.0.0.1] (p578adb1c.dip0.t-ipconnect.de [87.138.219.28]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 6B154862CB; Sun, 16 Jul 2023 18:01:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1689523269; bh=LtYVyadH/FnXqUWMXy2/K0wmrTIf6a7Nlm2t6GoFhUM=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=GACKnjr1sXm4JtCZvS7xK48Qo9NgSZZJapvU8tDM99GE1rebPME9pdA9Gnbp07kO9 Hlmxewf0N/f91CmaMvkXVwhJz+0+/RZZ3KBRDu9B0UMqzDfersIA/p5NZEfy/9OK+Q julFM0mJPcv50kX+g8tVT2y0uQNNoNIuo85ArQRjTMSC5BXuHa6oiGjx3vLmEiXLQS GGsQAe+61ZiYO5ac6eXvhEMFMfy9DCgSCVQOLmqVa174OfOhq1Uoj5o9Gcaotk+ced dB4vS5DdbgOIdeCr3W1y9vXiJrwfj3QimcbWbUjjJHYtqiC6qL7yTFDi/NjOf65wSK A7m/ziBvO3SPg== Message-ID: <1a5c804c-b054-ea6a-2f5c-eceaa0421c0f@denx.de> Date: Sun, 16 Jul 2023 18:01:07 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v2 2/5] usb: dwc3-generic: Return early when there is no child node Content-Language: en-US To: Jonas Karlman , Kever Yang , Simon Glass , Philipp Tomsich Cc: Akash Gajjar , Jagan Teki , FUKAUMI Naoki , u-boot@lists.denx.de References: <20230715231020.1694772-1-jonas@kwiboo.se> <20230715231020.1694772-3-jonas@kwiboo.se> <6b4d2cc0-483c-24c4-22d1-efcff907456a@kwiboo.se> <3f6c0620-8ce7-0eff-6531-a9d8806a6191@denx.de> <1bb4c66f-5d39-4c5d-05d0-76210a400e85@kwiboo.se> From: Marek Vasut In-Reply-To: <1bb4c66f-5d39-4c5d-05d0-76210a400e85@kwiboo.se> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean On 7/16/23 09:57, Jonas Karlman wrote: > On 2023-07-16 03:19, Marek Vasut wrote: >> On 7/16/23 03:05, Jonas Karlman wrote: >>> On 2023-07-16 02:58, Marek Vasut wrote: >>>> On 7/16/23 01:10, 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 >>>>> --- >>>>> 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; >>>> >>>> What does device_find_first_child() return in your case ? ENODEV or ENOSYS ? >>> >>> device_find_first_child always returns 0, same as is documented. >>> >>> See https://source.denx.de/u-boot/u-boot/-/blob/master/drivers/core/device.c#L931-941>> >> Ah, I see, thanks for clarifying. >> >> Reviewed-by: Marek Vasut >> >> Could you fix mtu3_plat.c the same way and switch this function to >> return void ? (separate series for these two things please) > > Sorry, not sure when I would have time for that, currently way too much > ongoing in my pipeline :-) All right, I sent those two patches, it was trivial. But now I am out of time for reviewing today, so this series has to wait until the next round, likely next week.