]> git.baikalelectronics.ru Git - kernel.git/commit
media: cec-pin.c: disabling the adapter cannot call kthread_stop
authorHans Verkuil <hverkuil-cisco@xs4all.nl>
Fri, 6 May 2022 07:15:40 +0000 (09:15 +0200)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Fri, 13 May 2022 09:27:19 +0000 (11:27 +0200)
commitd6171ea39308eb8aa7ed9892e8209ac576287f3e
tree7a508d0238bc08a9537eecc79da4ad04d58c511e
parent5eb0d52ae08e78a8b6aa4cecbec5658caae7ff08
media: cec-pin.c: disabling the adapter cannot call kthread_stop

When the adap_enable callback is called the adap->lock is held.
When disabling the adapter it attempts to stop the kthread that
deals with receiving and transmitting messages. However, kthread_stop
waits for the thread to stop, so all that time adap->lock is held.

Unfortunately, the kernel thread itself can call functions that take
that same lock, so a deadlock can occur.

Change the logic to keep the kernel thread running and instead when
disabling the adapter, just set the pin to high, go to idle and then
to state OFF and disable the interrupt. Only stop the kernel thread
when the adapter is deleted.

This way disabling the adapter will not wait for anything and the
deadlock is avoided.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/media/cec/core/cec-pin.c