]> Git Repo - linux.git/commitdiff
of: fix phandle cache creation for DTs with no phandles
authorRob Herring <[email protected]>
Tue, 11 Sep 2018 14:28:14 +0000 (09:28 -0500)
committerRob Herring <[email protected]>
Tue, 11 Sep 2018 16:28:40 +0000 (11:28 -0500)
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: [email protected] # 4.17+
Reported-by: Finn Thain <[email protected]>
Tested-by: Stan Johnson <[email protected]>
Reviewed-by: Frank Rowand <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Signed-off-by: Rob Herring <[email protected]>
drivers/of/base.c

index 9095b8290150c5bd2b8da3916d9f6c9243f24c56..74eaedd5b860f1c1fd42faa187d5cda802d0ae8e 100644 (file)
@@ -140,6 +140,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;
 
This page took 0.056553 seconds and 4 git commands to generate.