• Hans Verkuil's avatar
    media: cec-pin.c: disabling the adapter cannot call kthread_stop · 60965c6a
    Hans Verkuil authored
    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: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
    Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
    60965c6a
cec-pin.c 37.1 KB