[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180924113119.652905591@linuxfoundation.org>
Date: Mon, 24 Sep 2018 13:52:06 +0200
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: linux-kernel@...r.kernel.org
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
stable@...r.kernel.org, Finn Thain <fthain@...egraphics.com.au>,
Stan Johnson <userm57@...oo.com>,
Frank Rowand <frank.rowand@...y.com>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Rob Herring <robh@...nel.org>
Subject: [PATCH 4.18 140/235] of: fix phandle cache creation for DTs with no phandles
4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rob Herring <robh@...nel.org>
commit e54192b48da75f025ae4b277925eaf6aca1d13bd upstream.
With commit 0b3ce78e90fc ("of: cache phandle nodes to reduce cost of
of_find_node_by_phandle()"), a G3 PowerMac fails to boot. The root cause
is the DT for this system has no phandle properties when booted with
BootX. of_populate_phandle_cache() does not handle the case of no
phandles correctly. The problem is roundup_pow_of_two() for 0 is
undefined. The implementation subtracts 1 underflowing and then things
are in the weeds.
Fixes: 0b3ce78e90fc ("of: cache phandle nodes to reduce cost of of_find_node_by_phandle()")
Cc: stable@...r.kernel.org # 4.17+
Reported-by: Finn Thain <fthain@...egraphics.com.au>
Tested-by: Stan Johnson <userm57@...oo.com>
Reviewed-by: Frank Rowand <frank.rowand@...y.com>
Cc: Benjamin Herrenschmidt <benh@...nel.crashing.org>
Signed-off-by: Rob Herring <robh@...nel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
---
drivers/of/base.c | 3 +++
1 file changed, 3 insertions(+)
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -118,6 +118,9 @@ void of_populate_phandle_cache(void)
if (np->phandle && np->phandle != OF_PHANDLE_ILLEGAL)
phandles++;
+ if (!phandles)
+ goto out;
+
cache_entries = roundup_pow_of_two(phandles);
phandle_cache_mask = cache_entries - 1;
Powered by blists - more mailing lists