[PATCH v1 1/2] tests/chamelium/audio: Fix ALSA handle leak on skipped audio config

Mohammed Bilal
2026-03-04T10:08:44Z

When the audio configuration check fails, the loop continues without
closing previously opened ALSA handles. This leads to handle leaks
across iterations and may eventually cause file descriptor exhaustion
or configuration failures.

Fix by ensuring the handles are closed before continuing.

Signed-off-by: Mohammed Bilal <mohammed.bilal@intel.com>
---
tests/chamelium/kms_chamelium_audio.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tests/chamelium/kms_chamelium_audio.c b/tests/chamelium/kms_chamelium_audio.c
index df8d27c0c..2967e3c50 100644
--- a/tests/chamelium/kms_chamelium_audio.c
+++ b/tests/chamelium/kms_chamelium_audio.c
@@ -762,8 +762,10 @@ static void test_display_audio(chamelium_data_t *data,
sampling_rate = test_sampling_rates[i];

if (!check_audio_configuration(alsa, format, channels,
- sampling_rate))
+ sampling_rate)) {
+ alsa_close_output(alsa);
continue;
+ }

run = true;

--
2.48.1