]> git.baikalelectronics.ru Git - kernel.git/commit
arch: xtensa: platforms: Fix deadlock in rs_close()
authorDuoming Zhou <duoming@zju.edu.cn>
Thu, 7 Apr 2022 15:44:30 +0000 (23:44 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 9 May 2022 07:14:40 +0000 (09:14 +0200)
commit3e2bae63f1c03f2f31fc38ba456b2c47ed6a7814
treee4210a29a036ca38e3ff5c1a0c6365468c7d5428
parent3e77a0bbbdd221914cf1a2dc028a86beaa267e2d
arch: xtensa: platforms: Fix deadlock in rs_close()

[ Upstream commit c7f4610fbed78b6434f9d5af5913f8f4b71194a6 ]

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

   (Thread 1)              |      (Thread 2)
                           | rs_open()
rs_close()                 |  mod_timer()
 spin_lock_bh() //(1)      |  (wait a time)
 ...                       | rs_poll()
 del_timer_sync()          |  spin_lock() //(2)
 (wait timer to stop)      |  ...

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

This patch deletes the redundant timer_lock in order to
prevent the deadlock. Because there is no race condition
between rs_close, rs_open and rs_poll.

Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
Message-Id: <20220407154430.22387-1-duoming@zju.edu.cn>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/xtensa/platforms/iss/console.c