media: ngene: BUG: spinlock bad magic in irq_handler() on early IRQ
From: Jaeyoung Chung
Date: Wed Jun 10 2026 - 07:25:05 EST
Hi,
ngene_start() in drivers/media/pci/ngene/ngene-core.c registers the
interrupt handler with request_irq() before it initializes
dev->cmd_lock with spin_lock_init(). If an interrupt arrives before
spin_lock_init() runs, the handler acquires an uninitialized spinlock,
which triggers a kernel warning.
The probe path, in ngene_start():
stat = request_irq(dev->pci_dev->irq, irq_handler,
IRQF_SHARED, "nGene", (void *)dev); /* register handler */
...
spin_lock_init(&dev->cmd_lock); /* initialize lock */
The interrupt handler, irq_handler(), takes the lock:
spin_lock(&dev->cmd_lock);
If the device raises an interrupt before spin_lock_init() runs, the
handler acquires dev->cmd_lock while it is still uninitialized, which
triggers "BUG: spinlock bad magic" when CONFIG_DEBUG_SPINLOCK is
enabled.
Suggested fix: move spin_lock_init(&dev->cmd_lock) above request_irq(),
so the lock is valid before the handler can run.
Reported-by: Sangyun Kim <sangyun.kim@xxxxxxxxx>
Reported-by: Kyungwook Boo <bookyungwook@xxxxxxxxx>
Thanks,
Jaeyoung Chung