All of lore.kernel.org
 help / color / mirror / Atom feed
* Bug: lock problem for the function of_find_node_by_name
@ 2025-03-08 10:00 Ryder Wang
  2025-03-11 13:13 ` Rob Herring
  0 siblings, 1 reply; 4+ messages in thread
From: Ryder Wang @ 2025-03-08 10:00 UTC (permalink / raw)
  To: devicetree@vger.kernel.org

It looks there is a potential bug in some device tree function in Kernel code (It does not depend on the version of the kernel). 

One device tree function of_find_node_by_name() calls raw_spin_lock_irqsave() to lock. Then it calls of_node_put(), before unlocking (raw_spin_unlock_irqrestore). of_node_put() will call kernfs_remove() in some cases. So problem is here: kernfs_remove() will always call down_write() which might make the process sleep. As we know, sleep is not allowed between lock and unlock of spin lock. That's why there is might_sleep checking within down_write(), as there may be dead lock risk or disabling interrupt too long.

The actual call trace is like this:
of_find_node_by_name
    raw_spin_lock_irqsave
        ...
        kernfs_remove
            down_write
        ...
    raw_spin_unlock_irqrestore

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-03-12 14:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-08 10:00 Bug: lock problem for the function of_find_node_by_name Ryder Wang
2025-03-11 13:13 ` Rob Herring
2025-03-12  1:41   ` Ryder Wang
2025-03-12 14:19     ` Rob Herring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.