]> git.baikalelectronics.ru Git - kernel.git/commit
of: overlay: Fix (un)locking in of_overlay_apply()
authorGeert Uytterhoeven <geert+renesas@glider.be>
Tue, 5 Dec 2017 15:27:03 +0000 (16:27 +0100)
committerRob Herring <robh@kernel.org>
Wed, 6 Dec 2017 22:08:30 +0000 (16:08 -0600)
commitc58a85af3d14092872c6f28cb793c5185dff070a
tree09efbc32025fa3cf552b30155a9309fc5785fb78
parentdcba090f11fd4bad284829f8cca8fc1380147364
of: overlay: Fix (un)locking in of_overlay_apply()

The special overlay mutex is taken first, hence it should be released
last in the error path.

of_resolve_phandles() must be called with of_mutex held.  Without it, a
node and new phandle could be added via of_attach_node(), making the max
phandle wrong.

free_overlay_changeset() must be called with of_mutex held, if any
non-trivial cleanup is to be done.

Hence move "mutex_lock(&of_mutex)" up, as suggested by Frank, and merge
the two tail statements of the success and error paths, now they became
identical.

Note that while the two mutexes are adjacent, we still need both:
__of_changeset_apply_notify(), which is called by __of_changeset_apply()
unlocks of_mutex, then does notifications then locks of_mutex.  So the
mutex get released in the middle of of_overlay_apply()

Fixes: 61db79b937f1b943 ("of: overlay: avoid race condition between applying multiple overlays")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Frank Rowand <frank.rowand@sony.com>
Signed-off-by: Rob Herring <robh@kernel.org>
drivers/of/overlay.c