2017-04-18 00:29:32

by Tyrel Datwyler

[permalink] [raw]
Subject: [PATCH] of: fix "/cpus" reference leak in of_numa_parse_cpu_nodes()

The call to of_find_node_by_path("/cpus") returns the cpus device_node
with its reference count incremented. There is no matching of_node_put()
call in of_numa_parse_cpu_nodes() which results in a leaked reference
to the "/cpus" node.

This patch adds an of_node_put() to release the reference.

fixes: 298535c00a2c ("of, numa: Add NUMA of binding implementation.")
Signed-off-by: Tyrel Datwyler <[email protected]>
---
drivers/of/of_numa.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/of/of_numa.c b/drivers/of/of_numa.c
index a53982a..2db1f7a 100644
--- a/drivers/of/of_numa.c
+++ b/drivers/of/of_numa.c
@@ -57,6 +57,8 @@ static void __init of_numa_parse_cpu_nodes(void)
else
node_set(nid, numa_nodes_parsed);
}
+
+ of_node_put(cpus);
}

static int __init of_numa_parse_memory_nodes(void)
--
1.8.3.1


2017-04-18 15:17:08

by David Daney

[permalink] [raw]
Subject: Re: [PATCH] of: fix "/cpus" reference leak in of_numa_parse_cpu_nodes()

On 04/17/2017 05:29 PM, Tyrel Datwyler wrote:
> The call to of_find_node_by_path("/cpus") returns the cpus device_node
> with its reference count incremented. There is no matching of_node_put()
> call in of_numa_parse_cpu_nodes() which results in a leaked reference
> to the "/cpus" node.
>
> This patch adds an of_node_put() to release the reference.

Good catch:
Acked-by: David Daney <[email protected]>

>
> fixes: 298535c00a2c ("of, numa: Add NUMA of binding implementation.")
> Signed-off-by: Tyrel Datwyler <[email protected]>
> ---
> drivers/of/of_numa.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/of/of_numa.c b/drivers/of/of_numa.c
> index a53982a..2db1f7a 100644
> --- a/drivers/of/of_numa.c
> +++ b/drivers/of/of_numa.c
> @@ -57,6 +57,8 @@ static void __init of_numa_parse_cpu_nodes(void)
> else
> node_set(nid, numa_nodes_parsed);
> }
> +
> + of_node_put(cpus);
> }
>
> static int __init of_numa_parse_memory_nodes(void)
>

2017-04-18 16:09:20

by Rob Herring

[permalink] [raw]
Subject: Re: [PATCH] of: fix "/cpus" reference leak in of_numa_parse_cpu_nodes()

On Tue, Apr 18, 2017 at 10:16 AM, David Daney <[email protected]> wrote:
> On 04/17/2017 05:29 PM, Tyrel Datwyler wrote:
>>
>> The call to of_find_node_by_path("/cpus") returns the cpus device_node
>> with its reference count incremented. There is no matching of_node_put()
>> call in of_numa_parse_cpu_nodes() which results in a leaked reference
>> to the "/cpus" node.
>>
>> This patch adds an of_node_put() to release the reference.
>
>
> Good catch:
> Acked-by: David Daney <[email protected]>

Applied, thanks.

Rob