ALSA: hda - Fix potential endless loop at applying quirks
authorTakashi Iwai <tiwai@suse.de>
Thu, 29 Aug 2019 07:52:02 +0000 (09:52 +0200)
committerTakashi Iwai <tiwai@suse.de>
Thu, 29 Aug 2019 12:40:07 +0000 (14:40 +0200)
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")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/hda_auto_parser.c

index 92390d457567effa041306600d1bc6c5962cad05..18e6546b44675c7f7deee917f3066b828896cb88 100644 (file)
@@ -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;
        }
 }