mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: linux-sound@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH v2 5/5] ALSA: hda: Add NULL check for the driver pointer at unsol event work
Date: Fri,  9 Oct 2026 15:33:39 +0200	[thread overview]
Message-ID: <20261009133341.440917-6-tiwai@suse.de> (raw)
In-Reply-To: <20261009133341.440917-1-tiwai@suse.de>

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@suse.de>
---
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


      parent reply	other threads:[~2026-10-09 13:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-09 13:33 [PATCH v2 0/5] ALSA: yet a few more fixes for AI bug reports Takashi Iwai
2026-10-09 13:33 ` [PATCH v2 1/5] ALSA: line6: Fix handling of zero-length capture packets Takashi Iwai
2026-10-10  8:04   ` Takashi Iwai
2026-10-09 13:33 ` [PATCH v2 2/5] ALSA: hda: Disable unsol event handling at error and shutdown paths Takashi Iwai
2026-10-09 13:33 ` [PATCH v2 3/5] ALSA: hda: Add lock around codec->registered flag manipulations Takashi Iwai
2026-10-09 13:33 ` [PATCH v2 4/5] ALSA: hda: Stop unsol event and jack polling at hda-ext device removal, too Takashi Iwai
2026-10-09 13:33 ` Takashi Iwai [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261009133341.440917-6-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®