]> git.baikalelectronics.ru Git - kernel.git/commit
of/fdt: Add mutex protection for calls to __unflatten_device_tree()
authorGuenter Roeck <linux@roeck-us.net>
Sun, 6 Dec 2015 00:13:53 +0000 (16:13 -0800)
committerRob Herring <robh@kernel.org>
Tue, 8 Dec 2015 15:50:42 +0000 (09:50 -0600)
commitc01a84b899d062fc6f12dc9b48cb8c4a56161e9f
tree9327896dc5df8d709029f8ded5ee2e0042e5e5a8
parenta703f4239bebe2b48dae61df69ae7c7b9f559652
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>
drivers/of/fdt.c