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] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 20 Feb 2019 11:02:56 +0000
From:   Måns Rullgård <mans@...sr.com>
To:     "Rafael J. Wysocki" <rafael@...nel.org>
Cc:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] platform: set of_node in platform_device_register_full()

"Rafael J. Wysocki" <rafael@...nel.org> writes:

> On Wed, Feb 20, 2019 at 11:41 AM Måns Rullgård <mans@...sr.com> wrote:
>>
>> "Rafael J. Wysocki" <rafael@...nel.org> writes:
>>
>> > On Mon, Feb 18, 2019 at 12:10 PM Måns Rullgård <mans@...sr.com> wrote:
>> >>
>> >> "Rafael J. Wysocki" <rafael@...nel.org> writes:
>> >>
>> >> > On Sat, Feb 16, 2019 at 5:50 PM Mans Rullgard <mans@...sr.com> wrote:
>> >> >>
>> >> >> If the provided fwnode is an OF node, set dev.of_node as well.
>> >> >>
>> >> >> Signed-off-by: Mans Rullgard <mans@...sr.com>
>> >> >> ---
>> >> >>  drivers/base/platform.c | 1 +
>> >> >>  1 file changed, 1 insertion(+)
>> >> >>
>> >> >> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
>> >> >> index dff82a3c2caa..853a1d0e5845 100644
>> >> >> --- a/drivers/base/platform.c
>> >> >> +++ b/drivers/base/platform.c
>> >> >> @@ -512,6 +512,7 @@ struct platform_device *platform_device_register_full(
>> >> >>
>> >> >>         pdev->dev.parent = pdevinfo->parent;
>> >> >>         pdev->dev.fwnode = pdevinfo->fwnode;
>> >> >> +       pdev->dev.of_node = of_node_get(to_of_node(pdev->dev.fwnode));
>> >> >
>> >> > of_node_get() generally does a kobject_get() on the node's kobject, so
>> >> > when is that reference dropped?  Or if it doesn't need to be dropped
>> >> > at all, why is this the case?
>> >>
>> >> platform_device_release() calls of_device_node_put().
>> >
>> > Yes, it does, but this is the reference that's already acquired for
>> > devices added while parsing DT, isn't it?
>> >
>> > Your change adds an extra reference AFAICS.
>> >
>> > Also, why is this patch needed?
>>
>> Some drivers are just shims that create extra "glue" devices with the DT
>> device as parent and have the real driver bind to these.  In other
>> cases, the same real driver matches the DT node directly.  When a glue
>> device is used, it needs to get a reference to the original DT node in
>> order for the main driver to access properties and child nodes.
>>
>> Right now, my problem is that the suxi-musb driver creates such a glue
>> device for the musb core driver to bind to without setting of_node.
>> This means devices attached to this USB interface don't get associated
>> with DT nodes, if present, the way they do with EHCI.
>
> You really should describe problems that you want to address in patch
> changelogs.  This helps a lot to understand the motivation for the
> changes.

Do you want me to send a new patch with the above explanation in the
commit message?

>> The sunxi-musb driver uses platform_device_register_full(), so this
>> seemed like the easiest way to let it set of_node of the new device.
>> Since this creates a second reference to the same node, of_node_get()
>> is required.
>
> But what about devices that already have of_node set at this point?
>
> Maybe check if of_node is NULL before trying to set it?

It's a brand new device allocated a few lines above.  of_node has to be
null here.

-- 
Måns Rullgård

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ