mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-04 13:30:08 -05:00
topology: various coverity fixes
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
6efa23f283
commit
0d97f53c25
3 changed files with 18 additions and 10 deletions
|
|
@ -880,8 +880,8 @@ int tplg_add_enum(snd_tplg_t *tplg, struct snd_tplg_enum_template *enum_ctl,
|
||||||
if (enum_ctl->texts != NULL) {
|
if (enum_ctl->texts != NULL) {
|
||||||
for (i = 0; i < num_items; i++) {
|
for (i = 0; i < num_items; i++) {
|
||||||
if (enum_ctl->texts[i] != NULL)
|
if (enum_ctl->texts[i] != NULL)
|
||||||
strncpy(ec->texts[i], enum_ctl->texts[i],
|
snd_strlcpy(ec->texts[i], enum_ctl->texts[i],
|
||||||
SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -124,12 +124,12 @@ static int tplg_parse_data_file(snd_config_t *cfg, struct tplg_elem *elem)
|
||||||
|
|
||||||
if (fclose(fp) == EOF) {
|
if (fclose(fp) == EOF) {
|
||||||
SNDERR("Cannot close data file.");
|
SNDERR("Cannot close data file.");
|
||||||
ret = -errno;
|
return -errno;
|
||||||
goto err;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
|
fclose(fp);
|
||||||
if (priv)
|
if (priv)
|
||||||
free(priv);
|
free(priv);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
@ -422,7 +422,7 @@ static unsigned int get_tuple_size(int type)
|
||||||
static int copy_tuples(struct tplg_elem *elem,
|
static int copy_tuples(struct tplg_elem *elem,
|
||||||
struct tplg_vendor_tuples *tuples, struct tplg_vendor_tokens *tokens)
|
struct tplg_vendor_tuples *tuples, struct tplg_vendor_tokens *tokens)
|
||||||
{
|
{
|
||||||
struct snd_soc_tplg_private *priv = elem->data;
|
struct snd_soc_tplg_private *priv = elem->data, *priv2;
|
||||||
struct tplg_tuple_set *tuple_set;
|
struct tplg_tuple_set *tuple_set;
|
||||||
struct tplg_tuple *tuple;
|
struct tplg_tuple *tuple;
|
||||||
struct snd_soc_tplg_vendor_array *array;
|
struct snd_soc_tplg_vendor_array *array;
|
||||||
|
|
@ -447,10 +447,17 @@ static int copy_tuples(struct tplg_elem *elem,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv != NULL)
|
if (priv != NULL) {
|
||||||
priv = realloc(priv, sizeof(*priv) + size);
|
priv2 = realloc(priv, sizeof(*priv) + size);
|
||||||
else
|
if (priv2 == NULL) {
|
||||||
|
free(priv);
|
||||||
|
priv = NULL;
|
||||||
|
} else {
|
||||||
|
priv = priv2;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
priv = calloc(1, sizeof(*priv) + size);
|
priv = calloc(1, sizeof(*priv) + size);
|
||||||
|
}
|
||||||
if (!priv)
|
if (!priv)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -237,8 +237,9 @@ static int tplg_load_config(const char *file, snd_config_t **cfg)
|
||||||
|
|
||||||
ret = snd_input_stdio_attach(&in, fp, 1);
|
ret = snd_input_stdio_attach(&in, fp, 1);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
fclose(fp);
|
||||||
SNDERR("error: could not attach stdio %s", file);
|
SNDERR("error: could not attach stdio %s", file);
|
||||||
goto err;
|
return ret;
|
||||||
}
|
}
|
||||||
ret = snd_config_top(&top);
|
ret = snd_config_top(&top);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
|
@ -261,7 +262,7 @@ static int tplg_load_config(const char *file, snd_config_t **cfg)
|
||||||
err_load:
|
err_load:
|
||||||
snd_config_delete(top);
|
snd_config_delete(top);
|
||||||
err:
|
err:
|
||||||
fclose(fp);
|
snd_input_close(in);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue