media: cx88: add error handling for snd_ctl_add

When snd_ctl_add fails, the lack of error-handling code may
cause unexpected results.

This patch adds error-handling code after calling snd_ctl_add.

Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This commit is contained in:
Zhouyang Jia 2018-06-11 03:41:58 -04:00 committed by Mauro Carvalho Chehab
parent 7534122d60
commit 6c8871baeb
1 changed files with 5 additions and 2 deletions

View File

@ -962,8 +962,11 @@ static int cx88_audio_initdev(struct pci_dev *pci,
goto error;
/* If there's a wm8775 then add a Line-In ALC switch */
if (core->sd_wm8775)
snd_ctl_add(card, snd_ctl_new1(&snd_cx88_alc_switch, chip));
if (core->sd_wm8775) {
err = snd_ctl_add(card, snd_ctl_new1(&snd_cx88_alc_switch, chip));
if (err < 0)
goto error;
}
strcpy(card->driver, "CX88x");
sprintf(card->shortname, "Conexant CX%x", pci->device);