Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[ALSA] ac97 - Fix potential negative array index

Fix the case cidx2 >= 0 and cidx2 < 0 which may result in negative
array index.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>

authored by

Takashi Iwai and committed by
Jaroslav Kysela
c19bcdc6 b90d7760

+3 -1
+3 -1
sound/pci/ac97/ac97_patch.c
··· 1467 1467 snd_ac97_write_cache(ac97, AC97_AD_CODEC_CFG, 0x0002); // ID1C 1468 1468 ac97->spec.ad18xx.codec_cfg[unchained_idx] = 0x0002; 1469 1469 if (cidx1 >= 0) { 1470 - if (patch_ad1881_chained1(ac97, cidx1, 0x0006)) // SDIE | ID1C 1470 + if (cidx2 < 0) 1471 + patch_ad1881_chained1(ac97, cidx1, 0); 1472 + else if (patch_ad1881_chained1(ac97, cidx1, 0x0006)) // SDIE | ID1C 1471 1473 patch_ad1881_chained1(ac97, cidx2, 0); 1472 1474 else if (patch_ad1881_chained1(ac97, cidx2, 0x0006)) // SDIE | ID1C 1473 1475 patch_ad1881_chained1(ac97, cidx1, 0);