From 796b48c0d24d6575b7726ead31a1c80981f5de53 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Tue, 11 Nov 2025 16:01:17 +0100 Subject: [PATCH] add missing return value changes for snd_config_get_id() calls Signed-off-by: Jaroslav Kysela --- src/conf.c | 3 ++- src/pcm/pcm.c | 4 ++-- src/topology/channel.c | 3 ++- src/topology/dapm.c | 3 ++- src/topology/data.c | 3 ++- src/topology/elem.c | 5 ++++- src/topology/pcm.c | 6 ++++-- 7 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/conf.c b/src/conf.c index 357d72ba..ce34ff10 100644 --- a/src/conf.c +++ b/src/conf.c @@ -4437,7 +4437,8 @@ int snd_config_hook_load_for_all_cards(snd_config_t *root, snd_config_t *config, if (snd_config_search(root, fdriver, &n) >= 0) { if (snd_config_get_string(n, &driver) < 0) { if (snd_config_get_type(n) == SND_CONFIG_TYPE_COMPOUND) { - snd_config_get_id(n, &driver); + if (snd_config_get_id(n, &driver) < 0) + goto __err; goto __std; } goto __err; diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c index c8804f3b..a6f500cb 100644 --- a/src/pcm/pcm.c +++ b/src/pcm/pcm.c @@ -2578,8 +2578,8 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name, #endif if (snd_config_get_type(pcm_conf) != SND_CONFIG_TYPE_COMPOUND) { char *val; - id = NULL; - snd_config_get_id(pcm_conf, &id); + if (snd_config_get_id(pcm_conf, &id) < 0) + id = NULL; val = NULL; snd_config_get_ascii(pcm_conf, &val); snd_error(PCM, "Invalid type for PCM %s%sdefinition (id: %s, value: %s)", name ? name : "", name ? " " : "", id, val); diff --git a/src/topology/channel.c b/src/topology/channel.c index 2e001a5d..5a83e146 100644 --- a/src/topology/channel.c +++ b/src/topology/channel.c @@ -98,7 +98,8 @@ int tplg_parse_channel(snd_tplg_t *tplg, snd_config_t *cfg, return -EINVAL; channel += tplg->channel_idx; - snd_config_get_id(cfg, &id); + if (snd_config_get_id(cfg, &id) < 0) + return -EINVAL; tplg_dbg("\tChannel %s at index %d", id, tplg->channel_idx); channel_id = lookup_channel(id); diff --git a/src/topology/dapm.c b/src/topology/dapm.c index bb7fdf65..ac4d6085 100644 --- a/src/topology/dapm.c +++ b/src/topology/dapm.c @@ -381,7 +381,8 @@ int tplg_parse_dapm_graph(snd_tplg_t *tplg, snd_config_t *cfg, return -EINVAL; } - snd_config_get_id(cfg, &graph_id); + if (snd_config_get_id(cfg, &graph_id) < 0) + return -EINVAL; snd_config_for_each(i, next, cfg) { const char *id; diff --git a/src/topology/data.c b/src/topology/data.c index b1a2e23a..6869e3eb 100644 --- a/src/topology/data.c +++ b/src/topology/data.c @@ -792,7 +792,8 @@ static int parse_tuple_set(snd_config_t *cfg, unsigned int tuple_val; int type, ival; - snd_config_get_id(cfg, &id); + if (snd_config_get_id(cfg, &id) < 0) + return -EINVAL; type = get_tuple_type(id); if (type < 0) { diff --git a/src/topology/elem.c b/src/topology/elem.c index feaeafbb..4708d2f7 100644 --- a/src/topology/elem.c +++ b/src/topology/elem.c @@ -423,7 +423,10 @@ struct tplg_elem* tplg_elem_new_common(snd_tplg_t *tplg, /* do we get name from cfg */ if (cfg) { - snd_config_get_id(cfg, &id); + if (snd_config_get_id(cfg, &id) < 0) { + free(elem); + return NULL; + } snd_strlcpy(elem->id, id, SNDRV_CTL_ELEM_ID_NAME_MAXLEN); elem->id[SNDRV_CTL_ELEM_ID_NAME_MAXLEN - 1] = 0; /* as we insert new elem based on the index value, move index diff --git a/src/topology/pcm.c b/src/topology/pcm.c index db06d041..3cfc631e 100644 --- a/src/topology/pcm.c +++ b/src/topology/pcm.c @@ -627,7 +627,8 @@ static int tplg_parse_streams(snd_tplg_t *tplg ATTRIBUTE_UNUSED, const char *id, *value; int stream; - snd_config_get_id(cfg, &id); + if (snd_config_get_id(cfg, &id) < 0) + return -EINVAL; tplg_dbg("\t%s:", id); @@ -750,7 +751,8 @@ static int tplg_parse_fe_dai(snd_tplg_t *tplg ATTRIBUTE_UNUSED, const char *id; unsigned int dai_id; - snd_config_get_id(cfg, &id); + if (snd_config_get_id(cfg, &id) < 0) + return -EINVAL; tplg_dbg("\t\tFE DAI %s:", id); snd_strlcpy(pcm->dai_name, id, SNDRV_CTL_ELEM_ID_NAME_MAXLEN); -- 2.47.3