Skip to content

pcm: reject invalid multi bindings without assertions - #524

Open
HarshRajSinghania wants to merge 1 commit into
alsa-project:masterfrom
HarshRajSinghania:fix/pcm-multi-sparse-binding
Open

pcm: reject invalid multi bindings without assertions#524
HarshRajSinghania wants to merge 1 commit into
alsa-project:masterfrom
HarshRajSinghania:fix/pcm-multi-sparse-binding

Conversation

@HarshRajSinghania

Copy link
Copy Markdown

Fixes #523

The multi PCM parser initializes unused binding slots with slave_idx == -1. snd_pcm_multi_open() previously evaluated schannels[i] < schannels_count[sidxs[i]] before checking for an unbound slot, causing a negative array index and an assertion abort for sparse binding configurations.

This patch:

  • skips unbound binding slots before dereferencing the slave index;
  • validates the slave index and channel explicitly;
  • returns -EINVAL instead of relying on assertions for malformed configuration.

Reproducer from #523:

pcm.null { type null }
pcm.poc {
    type multi
    slaves.a.pcm "null"
    slaves.a.channels 2
    bindings.0.slave a
    bindings.0.channel 0
    bindings.5000.slave a
    bindings.5000.channel 1
}

Before the patch, alsa-lib aborts with:

pcm_multi.c:1125: snd_pcm_multi_open: Assertion `schannels[i] < schannels_count[sidxs[i]]' failed.

The fix makes the malformed configuration fail cleanly with -EINVAL.

Reported and fixed by Harsh Raj Singhania.

@github-actions github-actions Bot added the signed off by Missing Signed-off-by: line. label Sep 11, 2026
Fixes alsa-project#523

Signed-off-by: Harsh Raj Singhania <raj.harshraut@gmail.com>
@HarshRajSinghania
HarshRajSinghania force-pushed the fix/pcm-multi-sparse-binding branch from a6848c1 to aa0a70b Compare September 11, 2026 19:34
@github-actions github-actions Bot removed the signed off by Missing Signed-off-by: line. label Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pcm_multi accepts sparse/unbound bindings and aborts via assertion

1 participant