]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ALSA: hda: Avoid WARN_ON() for HDMI chmap slot checks
authorTakashi Iwai <tiwai@suse.de>
Tue, 28 Apr 2026 06:17:56 +0000 (08:17 +0200)
committerTakashi Iwai <tiwai@suse.de>
Wed, 29 Apr 2026 05:49:09 +0000 (07:49 +0200)
At parsing the channel mapping for HDMI, the current code may spew
WARN_ON() unnecessarily for the case where only invalid (zero) channel
maps are given from the hardware.  Drop WARN_ON() and reorganize the
code a bit for avoiding the hdmi_slot over the array size.

Closes: https://bugzilla.kernel.org/show_bug.cgi?id=221390
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20260428061800.80527-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/hda/core/hdmi_chmap.c

index 7b276047f85a7d2849803eafb0f282378dab2a45..c897fc443467c2fc40d58eecb096d95093f676a5 100644 (file)
@@ -353,13 +353,16 @@ static void hdmi_std_setup_channel_mapping(struct hdac_chmap *chmap,
        if (hdmi_channel_mapping[ca][1] == 0) {
                int hdmi_slot = 0;
                /* fill actual channel mappings in ALSA channel (i) order */
-               for (i = 0; i < ch_alloc->channels; i++) {
-                       while (!WARN_ON(hdmi_slot >= 8) &&
-                              !ch_alloc->speakers[7 - hdmi_slot])
-                               hdmi_slot++; /* skip zero slots */
+               for (i = 0; i < ch_alloc->channels && hdmi_slot < 8; i++) {
+                       while (!ch_alloc->speakers[7 - hdmi_slot]) {
+                               /* skip zero slots */
+                               if (++hdmi_slot >= 8)
+                                       goto out;
+                       }
 
                        hdmi_channel_mapping[ca][i] = (i << 4) | hdmi_slot++;
                }
+       out:
                /* fill the rest of the slots with ALSA channel 0xf */
                for (hdmi_slot = 0; hdmi_slot < 8; hdmi_slot++)
                        if (!ch_alloc->speakers[7 - hdmi_slot])