]> git.baikalelectronics.ru Git - kernel.git/commit
drivers: net: hippi: Fix deadlock in rr_close()
authorDuoming Zhou <duoming@zju.edu.cn>
Sun, 17 Apr 2022 12:55:19 +0000 (20:55 +0800)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 21 Apr 2022 08:30:45 +0000 (10:30 +0200)
commit27dd5116fffeb8faf20ca445006a9da04e12b30b
tree5f6c2e9d9c4f2a660332a774412fbe89bc21272f
parent9a0823007bbda00d7e505be6633beac5f2a09ffd
drivers: net: hippi: Fix deadlock in rr_close()

There is a deadlock in rr_close(), which is shown below:

   (Thread 1)                |      (Thread 2)
                             | rr_open()
rr_close()                   |  add_timer()
 spin_lock_irqsave() //(1)   |  (wait a time)
 ...                         | rr_timer()
 del_timer_sync()            |  spin_lock_irqsave() //(2)
 (wait timer to stop)        |  ...

We hold rrpriv->lock in position (1) of thread 1 and
use del_timer_sync() to wait timer to stop, but timer handler
also need rrpriv->lock in position (2) of thread 2.
As a result, rr_close() will block forever.

This patch extracts del_timer_sync() from the protection of
spin_lock_irqsave(), which could let timer handler to obtain
the needed lock.

Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
Link: https://lore.kernel.org/r/20220417125519.82618-1-duoming@zju.edu.cn
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/hippi/rrunner.c