Skip to content

Commit 67de40c

Browse files
Su Huitiwai
authored andcommitted
ALSA: ac97: Fix possible error value of *rac97
Before committing 79597c8, *rac97 always be NULL if there is an error. When error happens, make sure *rac97 is NULL is safer. For examble, in snd_vortex_mixer(): err = snd_ac97_mixer(pbus, &ac97, &vortex->codec); vortex->isquad = ((vortex->codec == NULL) ? 0 : (vortex->codec->ext_id&0x80)); If error happened but vortex->codec isn't NULL, this may cause some problems. Move the judgement order to be clearer and better. Fixes: 79597c8 ("ALSA: ac97: Fix possible NULL dereference in snd_ac97_mixer") Suggested-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Acked-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Signed-off-by: Su Hui <suhui@nfschina.com> Link: https://lore.kernel.org/r/20230823025212.1000961-1-suhui@nfschina.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 22459ef commit 67de40c

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

sound/pci/ac97/ac97_codec.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2069,10 +2069,9 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template,
20692069
.dev_disconnect = snd_ac97_dev_disconnect,
20702070
};
20712071

2072-
if (!rac97)
2073-
return -EINVAL;
2074-
if (snd_BUG_ON(!bus || !template))
2072+
if (snd_BUG_ON(!bus || !template || !rac97))
20752073
return -EINVAL;
2074+
*rac97 = NULL;
20762075
if (snd_BUG_ON(template->num >= 4))
20772076
return -EINVAL;
20782077
if (bus->codec[template->num])

0 commit comments

Comments
 (0)