• Geert Uytterhoeven's avatar
    of: overlay: Fix (un)locking in of_overlay_apply() · 5e474817
    Geert Uytterhoeven authored
    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: f948d6d8 ("of: overlay: avoid race condition between applying multiple overlays")
    Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
    Reviewed-by: default avatarFrank Rowand <frank.rowand@sony.com>
    Signed-off-by: default avatarRob Herring <robh@kernel.org>
    5e474817
Name
Last commit
Last update
Documentation Loading commit data...
arch Loading commit data...
block Loading commit data...
certs Loading commit data...
crypto Loading commit data...
drivers Loading commit data...
firmware Loading commit data...
fs Loading commit data...
include Loading commit data...
init Loading commit data...
ipc Loading commit data...
kernel Loading commit data...
lib Loading commit data...
mm Loading commit data...
net Loading commit data...
samples Loading commit data...
scripts Loading commit data...
security Loading commit data...
sound Loading commit data...
tools Loading commit data...
usr Loading commit data...
virt Loading commit data...
.cocciconfig Loading commit data...
.get_maintainer.ignore Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
.mailmap Loading commit data...
COPYING Loading commit data...
CREDITS Loading commit data...
Kbuild Loading commit data...
Kconfig Loading commit data...
MAINTAINERS Loading commit data...
Makefile Loading commit data...
README Loading commit data...