[PATCH v2 5/5] ALSA: hda: Add NULL check for the driver pointer at unsol event work
From: Takashi Iwai
Date: Fri Oct 09 2026 - 09:41:02 EST
snd_hdac_bus_process_unsol_events() assumes that the codec driver is
always set when it's accessible from the codec table. It's true in
general, but in a sheer timing, it might have been already NULLified
at the driver unbinding.
Although the codec removal should have been done properly by the
previous fixes, just for more safety, let's add a NULL check before
dereferencing and calling the driver's unsol_event callback.
Fixes: e7255c00b10e ("ALSA: hda: Skip event processing for unregistered codecs")
Signed-off-by: Takashi Iwai <tiwai@xxxxxxx>
---
v1->v2: fix bogus NULL check to a more correct one, mention it's just to be sure
sound/hda/core/bus.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/sound/hda/core/bus.c b/sound/hda/core/bus.c
index 8d4ed9834aaa..21af4b7c870d 100644
--- a/sound/hda/core/bus.c
+++ b/sound/hda/core/bus.c
@@ -182,10 +182,13 @@ static void snd_hdac_bus_process_unsol_events(struct work_struct *work)
codec = bus->caddr_tbl[caddr & 0x0f];
if (!codec || !codec->registered || codec->unsol_disabled)
continue;
- spin_unlock_irq(&bus->reg_lock);
+ if (!codec->dev.driver)
+ continue;
drv = drv_to_hdac_driver(codec->dev.driver);
- if (drv->unsol_event)
- drv->unsol_event(codec, res);
+ if (!drv->unsol_event)
+ continue;
+ spin_unlock_irq(&bus->reg_lock);
+ drv->unsol_event(codec, res);
spin_lock_irq(&bus->reg_lock);
}
spin_unlock_irq(&bus->reg_lock);
--
2.55.0