aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/of
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2015-12-05 19:13:53 -0500
committerRob Herring <robh@kernel.org>2015-12-08 10:50:42 -0500
commitf8062386671a596ca7022c61727a14a25679a0a1 (patch)
tree9327896dc5df8d709029f8ded5ee2e0042e5e5a8 /drivers/of
parentba85edbe0d39710dc74a2a9c6f90929b5722a53b (diff)
of/fdt: Add mutex protection for calls to __unflatten_device_tree()
__unflatten_device_tree() calls unflatten_dt_node(), which declares a static variable. It is therefore not reentrant. One of the callers of __unflatten_device_tree(), unflatten_device_tree(), is only called once during early initialization and does not need to be protected. The other caller, of_fdt_unflatten_tree(), can be called at any time, possibly multiple times in parallel. This can happen, for example, if multiple devicetree overlays have to be loaded and installed. Without this protection, errors such as the following may be seen. kernel: End of tree marker overwritten: e6a3a458 kernel: find_target_node: Failed to find target-indirect node at /fragment@0 kernel: __of_overlay_create: of_build_overlay_info() failed for tree@/ Add a mutex to of_fdt_unflatten_tree() to make the call reentrant. Cc: Pantelis Antoniou <pantelis.antoniou@konsulko.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Cc: stable@vger.kernel.org # v4.1+ Signed-off-by: Rob Herring <robh@kernel.org>
Diffstat (limited to 'drivers/of')
-rw-r--r--drivers/of/fdt.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 1bbe3a990ef1..655f79db7899 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -13,6 +13,7 @@
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/initrd.h> 14#include <linux/initrd.h>
15#include <linux/memblock.h> 15#include <linux/memblock.h>
16#include <linux/mutex.h>
16#include <linux/of.h> 17#include <linux/of.h>
17#include <linux/of_fdt.h> 18#include <linux/of_fdt.h>
18#include <linux/of_reserved_mem.h> 19#include <linux/of_reserved_mem.h>
@@ -436,6 +437,8 @@ static void *kernel_tree_alloc(u64 size, u64 align)
436 return kzalloc(size, GFP_KERNEL); 437 return kzalloc(size, GFP_KERNEL);
437} 438}
438 439
440static DEFINE_MUTEX(of_fdt_unflatten_mutex);
441
439/** 442/**
440 * of_fdt_unflatten_tree - create tree of device_nodes from flat blob 443 * of_fdt_unflatten_tree - create tree of device_nodes from flat blob
441 * 444 *
@@ -447,7 +450,9 @@ static void *kernel_tree_alloc(u64 size, u64 align)
447void of_fdt_unflatten_tree(const unsigned long *blob, 450void of_fdt_unflatten_tree(const unsigned long *blob,
448 struct device_node **mynodes) 451 struct device_node **mynodes)
449{ 452{
453 mutex_lock(&of_fdt_unflatten_mutex);
450 __unflatten_device_tree(blob, mynodes, &kernel_tree_alloc); 454 __unflatten_device_tree(blob, mynodes, &kernel_tree_alloc);
455 mutex_unlock(&of_fdt_unflatten_mutex);
451} 456}
452EXPORT_SYMBOL_GPL(of_fdt_unflatten_tree); 457EXPORT_SYMBOL_GPL(of_fdt_unflatten_tree);
453 458