lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <7ad737c4-1f61-488a-a8f9-32e80ad8f817@wanadoo.fr>
Date:   Sat, 4 Nov 2023 09:35:11 +0100
From:   Christophe JAILLET <christophe.jaillet@...adoo.fr>
To:     Stanley Chang[昌育德] 
        <stanley_chang@...ltek.com>
Cc:     "Thinh.Nguyen@...opsys.com" <Thinh.Nguyen@...opsys.com>,
        "conor+dt@...nel.org" <conor+dt@...nel.org>,
        "devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
        "gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>,
        "krzysztof.kozlowski+dt@...aro.org" 
        <krzysztof.kozlowski+dt@...aro.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
        "robh+dt@...nel.org" <robh+dt@...nel.org>
Subject: Re: RE: RE: [PATCH v6 1/2] usb: dwc3: add Realtek DHC RTD SoC dwc3
 glue layer driver

Le 03/11/2023 à 11:54, Stanley Chang[昌育德] a écrit :
> Hi Christophe,
> 
>> Le 01/11/2023 à 07:27, Stanley Chang[昌育德] a écrit :
>>> Hi CJ,
>>>
>>> I think these functions are not needed in remove function.
>>>
>>> In dwc3_rtk_probe_dwc3_core,
>>> I have used
>>> dwc3_node = of_get_compatible_child(node, "snps,dwc3"); and dwc3_pdev
>>> = of_find_device_by_node(dwc3_node);
>>>
>>> So, I call these put functions.
>>> platform_device_put(dwc3_pdev);
>>> of_node_put(dwc3_node);
>>
>> Yes, but you call it only in the error handling path of the function.
>>
>> I wonder if they should also be called in the remove function in order to
>> decrement the ref-counted reference.
>>
>>
>> Same in __get_dwc3_maximum_speed(), the reference taken by:
>>      dwc3_np = of_get_compatible_child(np, "snps,dwc3"); is never released.
>>
>>
>> See the comment at [1] to see what I mean.
>>
>>
>> [1]: https://elixir.bootlin.com/linux/v6.6/source/drivers/of/base.c#L681
> 
> You are right!
> For dwc3_pdev, dwc3_np or dwc3_node, I should add of_node_put to release them when the function exits.
> https://elixir.bootlin.com/linux/v6.5.10/source/drivers/usb/dwc3/dwc3-meson-g12a.c#L567
> 
> I will add a patch to fix this.
> 
> For example,
> diff --git a/drivers/usb/dwc3/dwc3-rtk.c b/drivers/usb/dwc3/dwc3-rtk.c
> index 590028e8fdcb..9d6f2a8bd6ce 100644
> --- a/drivers/usb/dwc3/dwc3-rtk.c
> +++ b/drivers/usb/dwc3/dwc3-rtk.c
> @@ -187,6 +187,7 @@ static enum usb_device_speed __get_dwc3_maximum_speed(struct device_node *np)
> 
>          ret = match_string(speed_names, ARRAY_SIZE(speed_names), maximum_speed);
> 
> +       of_node_put(dwc3_np);
>          return (ret < 0) ? USB_SPEED_UNKNOWN : ret;
>   }
> 
> @@ -339,6 +340,8 @@ static int dwc3_rtk_probe_dwc3_core(struct dwc3_rtk *rtk)
> 
>          switch_usb2_role(rtk, rtk->cur_role);
> 
> +       platform_device_put(dwc3_pdev);
> +       of_node_put(dwc3_node);
>          return 0;
> 
>   err_pdev_put:
> 

LGTM.

CJ

> 
> Thanks,
> Stanley
> 
>> CJ
>>>
>>> Thanks,
>>> Stanley
>>>
>>>> Hi,
>>>>
>>>> Is something like
>>>>           platform_device_put(dwc3_pdev);
>>>>           of_node_put(dwc3_node);
>>>> needed in the remove function?
>>>>
>>>> (as done in the error handling path of dwc3_rtk_probe_dwc3_core())
>>>>
>>>> Or should it be added at the end of dwc3_rtk_probe_dwc3_core() if the
>>>> reference are nor needed anymore when we leave the function?
>>>>
>>>> CJ
>>>>
>>>>> +     of_platform_depopulate(rtk->dev); }
>>>>> +
>>>>
>>>> ...
>>>
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ