Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] ASoC: stm32: sai: add missing put_device()
@ 2019-02-09 10:41 Wen Yang
  2019-02-11 15:09 ` Olivier MOYSAN
  2019-02-14 13:14 ` Applied "ASoC: stm32: sai: add missing put_device()" to the asoc tree Mark Brown
  0 siblings, 2 replies; 5+ messages in thread
From: Wen Yang @ 2019-02-09 10:41 UTC (permalink / raw)
  To: Olivier Moysan, Arnaud Pouliquen, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, Maxime Coquelin, Alexandre Torgue
  Cc: Wen Yang, alsa-devel, linux-stm32, linux-arm-kernel, linux-kernel

The of_find_device_by_node() takes a reference to the underlying device
structure, we should release that reference.

Fixes: 7dd0d835582f ("ASoC: stm32: sai: simplify sync modes management")
Signed-off-by: Wen Yang <yellowriver2010@hotmail.com>
---
 sound/soc/stm/stm32_sai.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/sound/soc/stm/stm32_sai.c b/sound/soc/stm/stm32_sai.c
index bcb35ca..14c9591 100644
--- a/sound/soc/stm/stm32_sai.c
+++ b/sound/soc/stm/stm32_sai.c
@@ -112,16 +112,21 @@ static int stm32_sai_set_sync(struct stm32_sai_data *sai_client,
 	if (!sai_provider) {
 		dev_err(&sai_client->pdev->dev,
 			"SAI sync provider data not found\n");
-		return -EINVAL;
+		ret = -EINVAL;
+		goto out_put_dev;
 	}
 
 	/* Configure sync client */
 	ret = stm32_sai_sync_conf_client(sai_client, synci);
 	if (ret < 0)
-		return ret;
+		goto out_put_dev;
 
 	/* Configure sync provider */
-	return stm32_sai_sync_conf_provider(sai_provider, synco);
+	ret = stm32_sai_sync_conf_provider(sai_provider, synco);
+
+out_put_dev:
+	put_device(&pdev->dev);
+	return ret;
 }
 
 static int stm32_sai_probe(struct platform_device *pdev)
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ASoC: stm32: sai: add missing put_device()
  2019-02-09 10:41 [PATCH] ASoC: stm32: sai: add missing put_device() Wen Yang
@ 2019-02-11 15:09 ` Olivier MOYSAN
  2019-02-13 14:41   ` Wen Yang
  2019-02-14 13:14 ` Applied "ASoC: stm32: sai: add missing put_device()" to the asoc tree Mark Brown
  1 sibling, 1 reply; 5+ messages in thread
From: Olivier MOYSAN @ 2019-02-11 15:09 UTC (permalink / raw)
  To: Wen Yang, Arnaud POULIQUEN, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, Maxime Coquelin, Alexandre TORGUE
  Cc: alsa-devel, linux-stm32, linux-arm-kernel, linux-kernel

Hi Wen,

On 2/9/19 11:41 AM, Wen Yang wrote:
> The of_find_device_by_node() takes a reference to the underlying device
> structure, we should release that reference.
> 
> Fixes: 7dd0d835582f ("ASoC: stm32: sai: simplify sync modes management")
> Signed-off-by: Wen Yang <yellowriver2010@hotmail.com>
> ---
>   sound/soc/stm/stm32_sai.c | 11 ++++++++---
>   1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/sound/soc/stm/stm32_sai.c b/sound/soc/stm/stm32_sai.c
> index bcb35ca..14c9591 100644
> --- a/sound/soc/stm/stm32_sai.c
> +++ b/sound/soc/stm/stm32_sai.c
> @@ -112,16 +112,21 @@ static int stm32_sai_set_sync(struct stm32_sai_data *sai_client,

goto error also in previous test
	if (!pdev) {
		...
		ret = -ENODEV;
		goto error;
	}

>   	if (!sai_provider) {
>   		dev_err(&sai_client->pdev->dev,
>   			"SAI sync provider data not found\n");
> -		return -EINVAL;
> +		ret = -EINVAL;
> +		goto out_put_dev;
>   	}
>   
>   	/* Configure sync client */
>   	ret = stm32_sai_sync_conf_client(sai_client, synci);
>   	if (ret < 0)
> -		return ret;
> +		goto out_put_dev;
>   
>   	/* Configure sync provider */
> -	return stm32_sai_sync_conf_provider(sai_provider, synco);
> +	ret = stm32_sai_sync_conf_provider(sai_provider, synco);
> +
> +out_put_dev:
> +	put_device(&pdev->dev);
> +	return ret;

Here I propose:
error:
	of_node_put(np_provider);
	return ret;

>   }
>   
>   static int stm32_sai_probe(struct platform_device *pdev)
> 

Thanks for your patch. Please, see my comments above.

Regards
Olivier


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ASoC: stm32: sai: add missing put_device()
  2019-02-11 15:09 ` Olivier MOYSAN
@ 2019-02-13 14:41   ` Wen Yang
  2019-02-14 10:39     ` Olivier MOYSAN
  0 siblings, 1 reply; 5+ messages in thread
From: Wen Yang @ 2019-02-13 14:41 UTC (permalink / raw)
  To: Olivier MOYSAN, Arnaud POULIQUEN, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, Maxime Coquelin, Alexandre TORGUE
  Cc: alsa-devel, linux-stm32, linux-arm-kernel, linux-kernel

From: Olivier MOYSAN <olivier.moysan@st.com>
Sent: 11 February 2019 15:09
To: Wen Yang; Arnaud POULIQUEN; Liam Girdwood; Mark Brown; Jaroslav Kysela; Takashi Iwai; Maxime Coquelin; Alexandre TORGUE
Cc: alsa-devel@alsa-project.org; linux-stm32@st-md-mailman.stormreply.com; linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ASoC: stm32: sai: add missing put_device()

>On 2/9/19 11:41 AM, Wen Yang wrote:
>> The of_find_device_by_node() takes a reference to the underlying device
>> structure, we should release that reference.
>>
>> Fixes: 7dd0d835582f ("ASoC: stm32: sai: simplify sync modes management")
>> Signed-off-by: Wen Yang <yellowriver2010@hotmail.com>
>> ---
>>   sound/soc/stm/stm32_sai.c | 11 ++++++++---
>>   1 file changed, 8 insertions(+), 3 deletions(-)
>>
>> diff --git a/sound/soc/stm/stm32_sai.c b/sound/soc/stm/stm32_sai.c
>> index bcb35ca..14c9591 100644
>> --- a/sound/soc/stm/stm32_sai.c
>> +++ b/sound/soc/stm/stm32_sai.c
>> @@ -112,16 +112,21 @@ static int stm32_sai_set_sync(struct stm32_sai_data *sai_client,
>
>goto error also in previous test
>       if (!pdev) {
>               ...
>               ret = -ENODEV;
>                goto error;
>        }
>
>>       if (!sai_provider) {
>>               dev_err(&sai_client->pdev->dev,
>>                       "SAI sync provider data not found\n");
>> -             return -EINVAL;
>> +             ret = -EINVAL;
>> +             goto out_put_dev;
>>       }
>>
>>       /* Configure sync client */
>>       ret = stm32_sai_sync_conf_client(sai_client, synci);
>>       if (ret < 0)
>> -             return ret;
>> +             goto out_put_dev;
>>
>>       /* Configure sync provider */
>> -     return stm32_sai_sync_conf_provider(sai_provider, synco);
>> +     ret = stm32_sai_sync_conf_provider(sai_provider, synco);
>> +
>> +out_put_dev:
>> +     put_device(&pdev->dev);
>> +     return ret;
>
>Here I propose:
>error:
>        of_node_put(np_provider);
>        return ret;
>
>>   }
>>
>>   static int stm32_sai_probe(struct platform_device *pdev)
>>

>Thanks for your patch. Please, see my comments above.

Thanks for your comments, in this patch we only fix the problem of missing put_device().
The problem of missing of_node_put() is a bit more complicated:
For the variable np_provider(np_sync_provider):
1, it is obtained by of_get_parent(), but it is not released;
2, error code not obtained when calling sai->pdata->set_sync()

We will submit another patch to fix the failure of np_sync_provider
Thank you.

Regards
Wen



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ASoC: stm32: sai: add missing put_device()
  2019-02-13 14:41   ` Wen Yang
@ 2019-02-14 10:39     ` Olivier MOYSAN
  0 siblings, 0 replies; 5+ messages in thread
From: Olivier MOYSAN @ 2019-02-14 10:39 UTC (permalink / raw)
  To: Wen Yang, Arnaud POULIQUEN, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, Maxime Coquelin, Alexandre TORGUE
  Cc: alsa-devel, linux-stm32, linux-arm-kernel, linux-kernel

Acked-by: Olivier Moysan <olivier.moysan@st.com>

On 2/13/19 3:41 PM, Wen Yang wrote:
> From: Olivier MOYSAN <olivier.moysan@st.com>
> Sent: 11 February 2019 15:09
> To: Wen Yang; Arnaud POULIQUEN; Liam Girdwood; Mark Brown; Jaroslav Kysela; Takashi Iwai; Maxime Coquelin; Alexandre TORGUE
> Cc: alsa-devel@alsa-project.org; linux-stm32@st-md-mailman.stormreply.com; linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH] ASoC: stm32: sai: add missing put_device()
> 
>> On 2/9/19 11:41 AM, Wen Yang wrote:
>>> The of_find_device_by_node() takes a reference to the underlying device
>>> structure, we should release that reference.
>>>
>>> Fixes: 7dd0d835582f ("ASoC: stm32: sai: simplify sync modes management")
>>> Signed-off-by: Wen Yang <yellowriver2010@hotmail.com>
>>> ---
>>>    sound/soc/stm/stm32_sai.c | 11 ++++++++---
>>>    1 file changed, 8 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/sound/soc/stm/stm32_sai.c b/sound/soc/stm/stm32_sai.c
>>> index bcb35ca..14c9591 100644
>>> --- a/sound/soc/stm/stm32_sai.c
>>> +++ b/sound/soc/stm/stm32_sai.c
>>> @@ -112,16 +112,21 @@ static int stm32_sai_set_sync(struct stm32_sai_data *sai_client,
>>
>> goto error also in previous test
>>        if (!pdev) {
>>                ...
>>                ret = -ENODEV;
>>                 goto error;
>>         }
>>
>>>        if (!sai_provider) {
>>>                dev_err(&sai_client->pdev->dev,
>>>                        "SAI sync provider data not found\n");
>>> -             return -EINVAL;
>>> +             ret = -EINVAL;
>>> +             goto out_put_dev;
>>>        }
>>>
>>>        /* Configure sync client */
>>>        ret = stm32_sai_sync_conf_client(sai_client, synci);
>>>        if (ret < 0)
>>> -             return ret;
>>> +             goto out_put_dev;
>>>
>>>        /* Configure sync provider */
>>> -     return stm32_sai_sync_conf_provider(sai_provider, synco);
>>> +     ret = stm32_sai_sync_conf_provider(sai_provider, synco);
>>> +
>>> +out_put_dev:
>>> +     put_device(&pdev->dev);
>>> +     return ret;
>>
>> Here I propose:
>> error:
>>         of_node_put(np_provider);
>>         return ret;
>>
>>>    }
>>>
>>>    static int stm32_sai_probe(struct platform_device *pdev)
>>>
> 
>> Thanks for your patch. Please, see my comments above.
> 
> Thanks for your comments, in this patch we only fix the problem of missing put_device().
> The problem of missing of_node_put() is a bit more complicated:
> For the variable np_provider(np_sync_provider):
> 1, it is obtained by of_get_parent(), but it is not released;
> 2, error code not obtained when calling sai->pdata->set_sync()
> 

I agree, release of np_sync_provider node is missing, as well as
returned error on set_sync.
So yes, this requires a dedicated patch.
Thanks

Regards
Olivier

> We will submit another patch to fix the failure of np_sync_provider
> Thank you.
> > Regards
> Wen
> 
> 
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Applied "ASoC: stm32: sai: add missing put_device()" to the asoc tree
  2019-02-09 10:41 [PATCH] ASoC: stm32: sai: add missing put_device() Wen Yang
  2019-02-11 15:09 ` Olivier MOYSAN
@ 2019-02-14 13:14 ` Mark Brown
  1 sibling, 0 replies; 5+ messages in thread
From: Mark Brown @ 2019-02-14 13:14 UTC (permalink / raw)
  To: Wen Yang
  Cc: alsa-devel, Olivier Moysan, Torgue, linux-kernel,
	Arnaud Pouliquen, Takashi Iwai, Liam Girdwood, Alexandre,
	Mark Brown, Maxime Coquelin, Jaroslav Kysela, linux-stm32,
	linux-arm-kernel

The patch

   ASoC: stm32: sai: add missing put_device()

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

From 1c3816a194870e7a6622345dab7fb56c7d708613 Mon Sep 17 00:00:00 2001
From: Wen Yang <yellowriver2010@hotmail.com>
Date: Sat, 9 Feb 2019 10:41:09 +0000
Subject: [PATCH] ASoC: stm32: sai: add missing put_device()

The of_find_device_by_node() takes a reference to the underlying device
structure, we should release that reference.

Fixes: 7dd0d835582f ("ASoC: stm32: sai: simplify sync modes management")
Signed-off-by: Wen Yang <yellowriver2010@hotmail.com>
Acked-by: Olivier Moysan <olivier.moysan@st.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/stm/stm32_sai.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/sound/soc/stm/stm32_sai.c b/sound/soc/stm/stm32_sai.c
index bcb35cae2a2c..14c9591aae42 100644
--- a/sound/soc/stm/stm32_sai.c
+++ b/sound/soc/stm/stm32_sai.c
@@ -112,16 +112,21 @@ static int stm32_sai_set_sync(struct stm32_sai_data *sai_client,
 	if (!sai_provider) {
 		dev_err(&sai_client->pdev->dev,
 			"SAI sync provider data not found\n");
-		return -EINVAL;
+		ret = -EINVAL;
+		goto out_put_dev;
 	}
 
 	/* Configure sync client */
 	ret = stm32_sai_sync_conf_client(sai_client, synci);
 	if (ret < 0)
-		return ret;
+		goto out_put_dev;
 
 	/* Configure sync provider */
-	return stm32_sai_sync_conf_provider(sai_provider, synco);
+	ret = stm32_sai_sync_conf_provider(sai_provider, synco);
+
+out_put_dev:
+	put_device(&pdev->dev);
+	return ret;
 }
 
 static int stm32_sai_probe(struct platform_device *pdev)
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-09 10:41 [PATCH] ASoC: stm32: sai: add missing put_device() Wen Yang
2019-02-11 15:09 ` Olivier MOYSAN
2019-02-13 14:41   ` Wen Yang
2019-02-14 10:39     ` Olivier MOYSAN
2019-02-14 13:14 ` Applied "ASoC: stm32: sai: add missing put_device()" to the asoc tree Mark Brown

Linux-ARM-Kernel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/0 linux-arm-kernel/git/0.git
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/1 linux-arm-kernel/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-arm-kernel linux-arm-kernel/ https://lore.kernel.org/linux-arm-kernel \
		linux-arm-kernel@lists.infradead.org infradead-linux-arm-kernel@archiver.kernel.org
	public-inbox-index linux-arm-kernel


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-arm-kernel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox