alsa: free card on error

This commit is contained in:
Wim Taymans 2021-11-17 12:55:51 +01:00
parent 5bc95234e8
commit f5f66d1718

View file

@ -55,18 +55,15 @@ static struct card *ensure_card(uint32_t index)
if (err < 0) {
char *name;
err = snd_card_get_name(index, &name);
if (err < 0) {
errno = -err;
return NULL;
}
if (err < 0)
goto error;
snprintf(card_name, sizeof(card_name), "%s", name);
free(name);
err = snd_use_case_mgr_open(&c->ucm, card_name);
if (err < 0) {
errno = -err;
return NULL;
}
if (err < 0)
goto error;
}
if ((snd_use_case_get(c->ucm, "_alibpref", &alibpref) != 0))
alibpref = NULL;
@ -75,6 +72,10 @@ static struct card *ensure_card(uint32_t index)
spa_list_append(&cards, &c->link);
return c;
error:
free(c);
errno = -err;
return NULL;
}
static void release_card(uint32_t index)