Skip to contentSkip to conversation

ALSA: hda - Fix potential endless loop at applying quirks

PATCH New Takashi Iwai 1 participant 1 message Aug 29, 2019 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: hda - Fix potential endless loop at applying quirks

Since the chained quirks via chained_before flag is applied before the depth check, it may lead to the endless recursive calls, when the chain were set up incorrectly. Fix it by moving the depth check at the beginning of the loop.

Fixes 1f57825077dc ("ALSA: hda - Add chained_before flag to the fixup entry")
---
 sound/pci/hda/hda_auto_parser.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sound/pci/hda/hda_auto_parser.c +2 -2
index 8a134f750bae..2c6d2becfe1a 100644
@@ -824,6 +824,8 @@ static void apply_fixup(struct hda_codec *codec, int id, int action, int depth)
 	while (id >= 0) {
 		const struct hda_fixup *fix = codec->fixup_list + id;
 
+		if (++depth > 10)
+			break;
 		if (fix->chained_before)
 			apply_fixup(codec, fix->chain_id, action, depth + 1);
 
@@ -863,8 +865,6 @@ static void apply_fixup(struct hda_codec *codec, int id, int action, int depth)
 		}
 		if (!fix->chained || fix->chained_before)
 			break;
-		if (++depth > 10)
-			break;
 		id = fix->chain_id;
 	}
 }
Signature · 1 line
2.16.4