of: dynamic: Refactor action prints to not use "%pOF" inside devtree_lock
authorRob Herring <robh@kernel.org>
Fri, 18 Aug 2023 20:40:57 +0000 (15:40 -0500)
committerRob Herring <robh@kernel.org>
Mon, 21 Aug 2023 14:23:55 +0000 (09:23 -0500)
commit914d9d831e6126a6e7a92e27fcfaa250671be42c
tree07c518abf9338f6aea334f7f6347c0371bd7a336
parent0aeae3788e28f64ccb95405d4dc8cd80637ffaea
of: dynamic: Refactor action prints to not use "%pOF" inside devtree_lock

While originally it was fine to format strings using "%pOF" while
holding devtree_lock, this now causes a deadlock.  Lockdep reports:

    of_get_parent from of_fwnode_get_parent+0x18/0x24
    ^^^^^^^^^^^^^
    of_fwnode_get_parent from fwnode_count_parents+0xc/0x28
    fwnode_count_parents from fwnode_full_name_string+0x18/0xac
    fwnode_full_name_string from device_node_string+0x1a0/0x404
    device_node_string from pointer+0x3c0/0x534
    pointer from vsnprintf+0x248/0x36c
    vsnprintf from vprintk_store+0x130/0x3b4

Fix this by moving the printing in __of_changeset_entry_apply() outside
the lock. As the only difference in the multiple prints is the action
name, use the existing "action_names" to refactor the prints into a
single print.

Fixes: a92eb7621b9fb2c2 ("lib/vsprintf: Make use of fwnode API to obtain node names and separators")
Cc: stable@vger.kernel.org
Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20230801-dt-changeset-fixes-v3-2-5f0410e007dd@kernel.org
Signed-off-by: Rob Herring <robh@kernel.org>
drivers/of/dynamic.c