diff mbox series

[25/28] ASoC: soc-core: initialize component list

Message ID 871rxz2idw.wl-kuninori.morimoto.gx@renesas.com (mailing list archive)
State New, archived
Headers show
Series ASoC: cleanup patches for soc-core | expand

Commit Message

Kuninori Morimoto Aug. 6, 2019, 1:30 a.m. UTC
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

snd_soc_component_initialize() isn't initialize component->list,
but we should do it.
This patch initialize it.

It might return without initializing in error case.
In such case, uninitialized list might be used at error handler.
This patch initializes all necessary variable before return.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-core.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Pierre-Louis Bossart Aug. 6, 2019, 3:07 p.m. UTC | #1
On 8/5/19 8:30 PM, Kuninori Morimoto wrote:
> 
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> snd_soc_component_initialize() isn't initialize component->list,

doesn't

> but we should do it.
> This patch initialize it.

initializes

> It might return without initializing in error case.
> In such case, uninitialized list might be used at error handler.
> This patch initializes all necessary variable before return.
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>   sound/soc/soc-core.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
> index 75b1770..666851b 100644
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
> @@ -2641,6 +2641,10 @@ static int snd_soc_component_initialize(struct snd_soc_component *component,
>   {
>   	struct snd_soc_dapm_context *dapm;
>   
> +	INIT_LIST_HEAD(&component->dai_list);
> +	INIT_LIST_HEAD(&component->list);

is this actually required or is this 'list' used for list management?

> +	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");
> @@ -2657,9 +2661,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;
>   }
>   
>
Kuninori Morimoto Aug. 7, 2019, 12:18 a.m. UTC | #2
Hi Pierre-Louis

Thank you for your English lesson :)

> > snd_soc_component_initialize() isn't initialize component->list,
> 
> doesn't
> 
> > but we should do it.
> > This patch initialize it.
> 
> initializes

Thanks !
I will fix these, and [15/28], [23/28] too

> > @@ -2641,6 +2641,10 @@ static int snd_soc_component_initialize(struct snd_soc_component *component,
> >   {
> >   	struct snd_soc_dapm_context *dapm;
> >   +	INIT_LIST_HEAD(&component->dai_list);
> > +	INIT_LIST_HEAD(&component->list);
> 
> is this actually required or is this 'list' used for list management?

Ahh, maybe be this is same comment for [16/28] from Ranjani.
I will fix it and Subject.


Thank you for your help !!
Best regards
---
Kuninori Morimoto
diff mbox series

Patch

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 75b1770..666851b 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2641,6 +2641,10 @@  static int snd_soc_component_initialize(struct snd_soc_component *component,
 {
 	struct snd_soc_dapm_context *dapm;
 
+	INIT_LIST_HEAD(&component->dai_list);
+	INIT_LIST_HEAD(&component->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");
@@ -2657,9 +2661,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;
 }