From: lorenzo.pieralisi@arm.com (Lorenzo Pieralisi)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/4] arm64: topology: Add support for topology DT bindings
Date: Mon, 24 Mar 2014 16:02:36 +0000 [thread overview]
Message-ID: <20140324160236.GB16245@red-moon> (raw)
In-Reply-To: <20140324154550.GL2269@sirena.org.uk>
On Mon, Mar 24, 2014 at 03:45:50PM +0000, Mark Brown wrote:
> On Mon, Mar 24, 2014 at 03:36:11PM +0000, Lorenzo Pieralisi wrote:
>
> > - for_each_possible_cpu(cpu) {
> > - if (of_get_cpu_node(cpu, NULL) == cpu_node)
> > + for_each_possible_cpu(cpu)
> > + if (of_get_cpu_node(cpu, NULL) == cpu_node) {
> > + of_node_put(cpu_node);
> > return cpu;
> > - }
> > + }
>
> of_get_cpu_node() doesn't visibly take a reference and isn't documented
> as doing such?
of_parse_phandle() does, am I right ?
> > pr_crit("Unable to find CPU node for %s\n", cpu_node->full_name);
> > +
> > + of_node_put(cpu_node);
>
> I don't understand this one - the caller passed in cpu_node, we didn't
> acquire a reference here so I'd expect the caller to be doing any frees
> that are needed.
cpu_node has to be put, since it is obtained through of_parse_phandle().
> > @@ -55,6 +58,7 @@ static int __init parse_core(struct device_node *core, int cluster_id,
> > if (t) {
> > leaf = false;
> > cpu = get_cpu_for_node(t);
> > + of_node_put(t);
> > if (cpu >= 0) {
> > cpu_topology[cpu].cluster_id = cluster_id;
> > cpu_topology[cpu].core_id = core_id;
> > @@ -64,7 +68,6 @@ static int __init parse_core(struct device_node *core, int cluster_id,
> > t->full_name);
> > return -EINVAL;
> > }
> > - of_node_put(t);
>
> This causes us to reference the just released t when displaying the
> error message in the error case (t->full_name in the quoted context).
> You're right that the reference is leaked in the error path but the free
> needs to be inside the error handling case.
Gah, right. I will let you fix it please as you deem fit.
> Of course all this refcounting does absolutely nothing for FDT but hey
> ho.
We comply with the interface, so that at least from an API standpoint
code is complete. I understand your point.
> > @@ -107,11 +110,11 @@ static int __init parse_cluster(struct device_node *cluster, int depth)
> > snprintf(name, sizeof(name), "cluster%d", i);
> > c = of_get_child_by_name(cluster, name);
> > if (c) {
> > + leaf = false;
> > ret = parse_cluster(c, depth + 1);
> > + of_node_put(c);
> > if (ret != 0)
> > return ret;
> > - leaf = false;
> > - of_node_put(c);
>
> I don't understand why you moved the assignment of leaf?
It makes it tidier, but that's just cosmetic and my opinion (but thanks
for having a look since it is not a significant change). Again, squash it
in as you deem fit.
Thanks !
Lorenzo
next prev parent reply other threads:[~2014-03-24 16:02 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-21 17:27 [PATCH 1/4] arm64: topology: Initialise default topology state immediately Mark Brown
2014-03-21 17:27 ` [PATCH 2/4] arm64: topology: Add support for topology DT bindings Mark Brown
2014-03-24 15:36 ` Lorenzo Pieralisi
2014-03-24 15:45 ` Mark Brown
2014-03-24 16:02 ` Lorenzo Pieralisi [this message]
2014-03-24 16:27 ` Mark Brown
2014-03-21 17:28 ` [PATCH 3/4] arm64: topology: Tell the scheduler about the relative power of cores Mark Brown
2014-03-21 17:28 ` [PATCH 4/4] arm64: topology: Provide relative power numbers for cores Mark Brown
-- strict thread matches above, loose matches on Subject: below --
2014-04-22 20:21 [PATCH 1/4] arm64: topology: Initialise default topology state immediately Mark Brown
2014-04-22 20:21 ` [PATCH 2/4] arm64: topology: Add support for topology DT bindings Mark Brown
2014-04-24 14:48 ` Lorenzo Pieralisi
2014-02-26 0:48 [PATCH 0/4] arm64: Topology Mark Brown
2014-02-26 0:48 ` [PATCH 2/4] arm64: topology: Add support for topology DT bindings Mark Brown
2014-02-25 4:25 [PATCH 0/4] arm64: topology: CPU topology support Mark Brown
2014-02-25 4:25 ` [PATCH 2/4] arm64: topology: Add support for topology DT bindings Mark Brown
2014-02-11 22:06 [PATCH 1/4] arm64: topology: Implement basic CPU topology support Mark Brown
2014-02-11 22:06 ` [PATCH 2/4] arm64: topology: Add support for topology DT bindings Mark Brown
2014-02-10 13:02 [PATCH 1/4] arm64: topology: Implement basic CPU topology support Mark Brown
2014-02-10 13:02 ` [PATCH 2/4] arm64: topology: Add support for topology DT bindings Mark Brown
2014-01-15 11:38 [PATCH v12 0/4] arm64 topology Mark Brown
2014-01-15 11:38 ` [PATCH 2/4] arm64: topology: Add support for topology DT bindings Mark Brown
2014-01-12 19:20 [PATCH v11 0/4] ARMv8 cpu topology Mark Brown
2014-01-12 19:20 ` [PATCH 2/4] arm64: topology: Add support for topology DT bindings Mark Brown
2014-01-14 11:43 ` Lorenzo Pieralisi
2014-01-14 12:36 ` Mark Brown
2014-01-08 19:12 [PATCH 1/4] arm64: topology: Implement basic CPU topology support Mark Brown
2014-01-08 19:12 ` [PATCH 2/4] arm64: topology: Add support for topology DT bindings Mark Brown
2014-01-09 12:50 ` Lorenzo Pieralisi
2014-01-09 13:26 ` Mark Brown
2014-01-08 17:10 [PATCH 1/4] arm64: topology: Implement basic CPU topology support Mark Brown
2014-01-08 17:10 ` [PATCH 2/4] arm64: topology: Add support for topology DT bindings Mark Brown
2014-01-08 18:23 ` Lorenzo Pieralisi
2014-01-08 18:32 ` Mark Brown
2013-12-19 20:06 [PATCH 0/4] arm64 topology support Mark Brown
2013-12-19 20:06 ` [PATCH 2/4] arm64: topology: Add support for topology DT bindings Mark Brown
2013-12-16 16:49 [PATCH 1/4] arm64: topology: Implement basic CPU topology support Mark Brown
2013-12-16 16:49 ` [PATCH 2/4] arm64: topology: Add support for topology DT bindings Mark Brown
2013-12-17 17:40 ` Lorenzo Pieralisi
2013-12-17 19:19 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140324160236.GB16245@red-moon \
--to=lorenzo.pieralisi@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox