[PATCH] ALSA: hda: trace PCM open only after assigning a stream

Slavin Liu posted 1 patch 1 week, 4 days ago
sound/hda/common/controller.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] ALSA: hda: trace PCM open only after assigning a stream
Posted by Slavin Liu 1 week, 4 days ago
Stream assignment can fail when hardware streams are exhausted.
Move the tracepoint after the NULL check because its payload accesses
the assigned stream tag.

Detected by static analysis and reviewed with AI-assisted source auditing.

Fixes: 184865085b88 ("ALSA: hda - rename hda_intel_trace.h to hda_controller_trace.h")
Assisted-by: LLM
Signed-off-by: Slavin Liu <bolin.liu@seu.edu.cn>
---
 sound/hda/common/controller.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/hda/common/controller.c b/sound/hda/common/controller.c
index afec5c5546ec..18dae022b324 100644
--- a/sound/hda/common/controller.c
+++ b/sound/hda/common/controller.c
@@ -586,11 +586,11 @@ static int azx_pcm_open(struct snd_pcm_substream *substream)
 	snd_hda_codec_pcm_get(apcm->info);
 	mutex_lock(&chip->open_mutex);
 	azx_dev = azx_assign_device(chip, substream);
-	trace_azx_pcm_open(chip, azx_dev);
 	if (azx_dev == NULL) {
 		err = -EBUSY;
 		goto unlock;
 	}
+	trace_azx_pcm_open(chip, azx_dev);
 	runtime->private_data = azx_dev;
 
 	runtime->hw = azx_pcm_hw;
Re: [PATCH] ALSA: hda: trace PCM open only after assigning a stream
Posted by Takashi Iwai 1 week, 3 days ago
On Sun, 13 Sep 2026 14:51:54 +0200,
Slavin Liu wrote:
> 
> Stream assignment can fail when hardware streams are exhausted.
> Move the tracepoint after the NULL check because its payload accesses
> the assigned stream tag.
> 
> Detected by static analysis and reviewed with AI-assisted source auditing.
> 
> Fixes: 184865085b88 ("ALSA: hda - rename hda_intel_trace.h to hda_controller_trace.h")
> Assisted-by: LLM
> Signed-off-by: Slavin Liu <bolin.liu@seu.edu.cn>

Applied now.

I think I wanted to track the error state, too, and that's likely the
reason the code was put there.  But, judging from the current code,
better to move as in this patch in the end.


thanks,

Takashi