extcon: ptn5150: Avoid IRQ vs probe race and drop mutex
The IRQ is being requested quite early in probe sequence, where neither
mutex has been taken, nor info->edev has been set yet. From this point on
one shall expect the handler to be called. The corresponding test for
!info->edev looks pointless being not protected by the mutex.
Moving the IRQ request to the end of probe sequence avoids the race against
ptn5150_check_state() and other init steps (devm_extcon_dev_allocate(),
devm_extcon_dev_register()).
Finally it becomes obvious that the worker function doesn't run
concurrently with anything else and we can drop the mutex completely.
The change has been motivated by the following crash:
Unable to handle kernel paging request at virtual address 006c727400353434
CPU: 1 UID: 0 PID: 74 Comm: kworker/1:2 6.18.0-next-20251212
Workqueue: events ptn5150_irq_work [extcon_ptn5150]
pc : 0x6c727400353434
lr : notifier_call_chain+0x80
Call trace:
0x6c727400353434 (P)
raw_notifier_call_chain+0x20
extcon_sync+0xd0
extcon_set_state_sync+0x3c
ptn5150_check_state+0xf8 [extcon_ptn5150]
ptn5150_irq_work [extcon_ptn5150]
process_one_work
worker_thread
kthread
ret_from_fork
Kernel panic - not syncing: Oops: Fatal exception
Cc: stable@vger.kernel.org
Fixes: 4ed754de2d66 ("extcon: Add support for ptn5150 extcon driver")
Signed-off-by: Alexander Sverdlin <alexander.sverdlin@siemens.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
1 file changed