ASoC: soc-core: initialize component list
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tue, 20 Aug 2019 05:05:16 +0000 (14:05 +0900)
committerMark Brown <broonie@kernel.org>
Thu, 22 Aug 2019 17:31:58 +0000 (18:31 +0100)
It might return without initializing in error case.
In such case, uninitialized variable might be used at error handler.
This patch initializes all necessary variable before return.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87zhk4zazt.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/soc-core.c

index 1be069c2ac8ded62f969de3aced094526317c126..1a17cb1bc03b27feb62ca23373fdcfd12a1c4999 100644 (file)
@@ -2647,6 +2647,9 @@ static int snd_soc_component_initialize(struct snd_soc_component *component,
 {
        struct snd_soc_dapm_context *dapm;
 
+       INIT_LIST_HEAD(&component->dai_list);
+       mutex_init(&component->io_mutex);
+
        component->name = fmt_single_name(dev, &component->id);
        if (!component->name) {
                dev_err(dev, "ASoC: Failed to allocate name\n");
@@ -2663,9 +2666,6 @@ static int snd_soc_component_initialize(struct snd_soc_component *component,
        dapm->idle_bias_off = !driver->idle_bias_on;
        dapm->suspend_bias_off = driver->suspend_bias_off;
 
-       INIT_LIST_HEAD(&component->dai_list);
-       mutex_init(&component->io_mutex);
-
        return 0;
 }