lkml.org 
[lkml]   [2021]   [Dec]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2 6/6] drivers: remoteproc: Add Xilinx r5 remoteproc driver
From
Date
On 12/13/21 8:31 PM, Tanmay Shah wrote:
>>> +static int zynqmp_r5_cluster_init(struct zynqmp_r5_cluster *cluster)
>>> +{
>>> [...]
>>> +
>>>
>>> +    i = 0;
>>> +    for_each_available_child_of_node(dev_node, child) {
>>> +        child_pdev = of_find_device_by_node(child);
>>> +        if (!child_pdev)
>> A return or a break in a for_each_available_child_of_node() will leak
>> the reference to the child node.
>
> Do you mean I have to use of_put_node for each child?

You have to put a `of_put_node(child)` before each break or return in
the loop.

If you search the kernel commit history for
for_each_available_child_of_node or for_each_child_of_node you'll find
many fixes for similar problems. For example
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e1b391e9712db

\
 
 \ /
  Last update: 2021-12-13 20:44    [W:0.066 / U:2.848 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site