linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: Intel: bytcht_es8316: Add missed put_device()
@ 2020-07-14  8:09 Jing Xiangfeng
  2020-07-14 13:33 ` Hans de Goede
  2020-07-16 23:57 ` Mark Brown
  0 siblings, 2 replies; 6+ messages in thread
From: Jing Xiangfeng @ 2020-07-14  8:09 UTC (permalink / raw)
  To: cezary.rojewski, pierre-louis.bossart, liam.r.girdwood, yang.jie,
	broonie, perex, tiwai, hdegoede, kuninori.morimoto.gx, paul
  Cc: alsa-devel, linux-kernel, jingxiangfeng

snd_byt_cht_es8316_mc_probe() misses to call put_device() in an error
path. Add the missed function call to fix it.

Fixes: ba49cf6f8e4a ("ASoC: Intel: bytcht_es8316: Add quirk for inverted jack detect")
Signed-off-by: Jing Xiangfeng <jingxiangfeng@huawei.com>
---
 sound/soc/intel/boards/bytcht_es8316.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sound/soc/intel/boards/bytcht_es8316.c b/sound/soc/intel/boards/bytcht_es8316.c
index 9e5fc9430628..ecbc58e8a37f 100644
--- a/sound/soc/intel/boards/bytcht_es8316.c
+++ b/sound/soc/intel/boards/bytcht_es8316.c
@@ -543,8 +543,10 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
 
 	if (cnt) {
 		ret = device_add_properties(codec_dev, props);
-		if (ret)
+		if (ret) {
+			put_device(codec_dev);
 			return ret;
+		}
 	}
 
 	devm_acpi_dev_add_driver_gpios(codec_dev, byt_cht_es8316_gpios);
-- 
2.17.1


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

* Re: [PATCH] ASoC: Intel: bytcht_es8316: Add missed put_device()
  2020-07-14  8:09 [PATCH] ASoC: Intel: bytcht_es8316: Add missed put_device() Jing Xiangfeng
@ 2020-07-14 13:33 ` Hans de Goede
  2020-07-14 15:32   ` Pierre-Louis Bossart
  2020-07-16 23:57 ` Mark Brown
  1 sibling, 1 reply; 6+ messages in thread
From: Hans de Goede @ 2020-07-14 13:33 UTC (permalink / raw)
  To: Jing Xiangfeng, cezary.rojewski, pierre-louis.bossart,
	liam.r.girdwood, yang.jie, broonie, perex, tiwai,
	kuninori.morimoto.gx, paul
  Cc: alsa-devel, linux-kernel

Hi,

On 7/14/20 10:09 AM, Jing Xiangfeng wrote:
> snd_byt_cht_es8316_mc_probe() misses to call put_device() in an error
> path. Add the missed function call to fix it.
> 
> Fixes: ba49cf6f8e4a ("ASoC: Intel: bytcht_es8316: Add quirk for inverted jack detect")
> Signed-off-by: Jing Xiangfeng <jingxiangfeng@huawei.com>

Patch looks good to me:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans


> ---
>   sound/soc/intel/boards/bytcht_es8316.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/sound/soc/intel/boards/bytcht_es8316.c b/sound/soc/intel/boards/bytcht_es8316.c
> index 9e5fc9430628..ecbc58e8a37f 100644
> --- a/sound/soc/intel/boards/bytcht_es8316.c
> +++ b/sound/soc/intel/boards/bytcht_es8316.c
> @@ -543,8 +543,10 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
>   
>   	if (cnt) {
>   		ret = device_add_properties(codec_dev, props);
> -		if (ret)
> +		if (ret) {
> +			put_device(codec_dev);
>   			return ret;
> +		}
>   	}
>   
>   	devm_acpi_dev_add_driver_gpios(codec_dev, byt_cht_es8316_gpios);
> 


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

* Re: [PATCH] ASoC: Intel: bytcht_es8316: Add missed put_device()
  2020-07-14 13:33 ` Hans de Goede
@ 2020-07-14 15:32   ` Pierre-Louis Bossart
  2020-07-14 19:29     ` Hans de Goede
  0 siblings, 1 reply; 6+ messages in thread
From: Pierre-Louis Bossart @ 2020-07-14 15:32 UTC (permalink / raw)
  To: Hans de Goede, Jing Xiangfeng, cezary.rojewski, liam.r.girdwood,
	yang.jie, broonie, perex, tiwai, kuninori.morimoto.gx, paul
  Cc: alsa-devel, linux-kernel



On 7/14/20 8:33 AM, Hans de Goede wrote:
> Hi,
> 
> On 7/14/20 10:09 AM, Jing Xiangfeng wrote:
>> snd_byt_cht_es8316_mc_probe() misses to call put_device() in an error
>> path. Add the missed function call to fix it.
>>
>> Fixes: ba49cf6f8e4a ("ASoC: Intel: bytcht_es8316: Add quirk for 
>> inverted jack detect")
>> Signed-off-by: Jing Xiangfeng <jingxiangfeng@huawei.com>
> 
> Patch looks good to me:
> 
> Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Actually the existing code looks quite odd to me:

if (cnt) {
	ret = device_add_properties(codec_dev, props);
	if (ret)
		return ret;
}

devm_acpi_dev_add_driver_gpios(codec_dev, byt_cht_es8316_gpios);
priv->speaker_en_gpio =
	gpiod_get_index(codec_dev, "speaker-enable", 0,
			/* see comment in byt_cht_es8316_resume */
			GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_NONEXCLUSIVE);
put_device(codec_dev);

if the first branch is not taken the put_device() will not be balanced.

Shouldn't this be:

if (cnt) {
	ret = device_add_properties(codec_dev, props);
	put_device(codec_dev);
	if (ret)
		return ret;
}

devm_acpi_dev_add_driver_gpios(codec_dev, byt_cht_es8316_gpios);
priv->speaker_en_gpio =
	gpiod_get_index(codec_dev, "speaker-enable", 0,
			/* see comment in byt_cht_es8316_resume */
			GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_NONEXCLUSIVE);
/* removed put_device(codec_dev); */

> 
> Regards,
> 
> Hans
> 
> 
>> ---
>>   sound/soc/intel/boards/bytcht_es8316.c | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/sound/soc/intel/boards/bytcht_es8316.c 
>> b/sound/soc/intel/boards/bytcht_es8316.c
>> index 9e5fc9430628..ecbc58e8a37f 100644
>> --- a/sound/soc/intel/boards/bytcht_es8316.c
>> +++ b/sound/soc/intel/boards/bytcht_es8316.c
>> @@ -543,8 +543,10 @@ static int snd_byt_cht_es8316_mc_probe(struct 
>> platform_device *pdev)
>>       if (cnt) {
>>           ret = device_add_properties(codec_dev, props);
>> -        if (ret)
>> +        if (ret) {
>> +            put_device(codec_dev);
>>               return ret;
>> +        }
>>       }
>>       devm_acpi_dev_add_driver_gpios(codec_dev, byt_cht_es8316_gpios);
>>
> 

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

* Re: [PATCH] ASoC: Intel: bytcht_es8316: Add missed put_device()
  2020-07-14 15:32   ` Pierre-Louis Bossart
@ 2020-07-14 19:29     ` Hans de Goede
  2020-07-16 16:48       ` Pierre-Louis Bossart
  0 siblings, 1 reply; 6+ messages in thread
From: Hans de Goede @ 2020-07-14 19:29 UTC (permalink / raw)
  To: Pierre-Louis Bossart, Jing Xiangfeng, cezary.rojewski,
	liam.r.girdwood, yang.jie, broonie, perex, tiwai,
	kuninori.morimoto.gx, paul
  Cc: alsa-devel, linux-kernel

Hi,

On 7/14/20 5:32 PM, Pierre-Louis Bossart wrote:
> 
> 
> On 7/14/20 8:33 AM, Hans de Goede wrote:
>> Hi,
>>
>> On 7/14/20 10:09 AM, Jing Xiangfeng wrote:
>>> snd_byt_cht_es8316_mc_probe() misses to call put_device() in an error
>>> path. Add the missed function call to fix it.
>>>
>>> Fixes: ba49cf6f8e4a ("ASoC: Intel: bytcht_es8316: Add quirk for inverted jack detect")
>>> Signed-off-by: Jing Xiangfeng <jingxiangfeng@huawei.com>
>>
>> Patch looks good to me:
>>
>> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
> 
> Actually the existing code looks quite odd to me:
> 
> if (cnt) {
>      ret = device_add_properties(codec_dev, props);
>      if (ret)
>          return ret;
> }
> 
> devm_acpi_dev_add_driver_gpios(codec_dev, byt_cht_es8316_gpios);
> priv->speaker_en_gpio =
>      gpiod_get_index(codec_dev, "speaker-enable", 0,
>              /* see comment in byt_cht_es8316_resume */
>              GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_NONEXCLUSIVE);
> put_device(codec_dev);
> 
> if the first branch is not taken the put_device() will not be balanced.

The get_device() does not come from the device_add_properties, it comes
from the earlier:

codec_dev = bus_find_device_by_name(&i2c_bus_type, NULL, codec_name);

call.

Regards,

Hans



> 
> Shouldn't this be:
> 
> if (cnt) {
>      ret = device_add_properties(codec_dev, props);
>      put_device(codec_dev);
>      if (ret)
>          return ret;
> }
> 
> devm_acpi_dev_add_driver_gpios(codec_dev, byt_cht_es8316_gpios);
> priv->speaker_en_gpio =
>      gpiod_get_index(codec_dev, "speaker-enable", 0,
>              /* see comment in byt_cht_es8316_resume */
>              GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_NONEXCLUSIVE);
> /* removed put_device(codec_dev); */
> 
>>
>> Regards,
>>
>> Hans
>>
>>
>>> ---
>>>   sound/soc/intel/boards/bytcht_es8316.c | 4 +++-
>>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/sound/soc/intel/boards/bytcht_es8316.c b/sound/soc/intel/boards/bytcht_es8316.c
>>> index 9e5fc9430628..ecbc58e8a37f 100644
>>> --- a/sound/soc/intel/boards/bytcht_es8316.c
>>> +++ b/sound/soc/intel/boards/bytcht_es8316.c
>>> @@ -543,8 +543,10 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
>>>       if (cnt) {
>>>           ret = device_add_properties(codec_dev, props);
>>> -        if (ret)
>>> +        if (ret) {
>>> +            put_device(codec_dev);
>>>               return ret;
>>> +        }
>>>       }
>>>       devm_acpi_dev_add_driver_gpios(codec_dev, byt_cht_es8316_gpios);
>>>
>>
> 


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

* Re: [PATCH] ASoC: Intel: bytcht_es8316: Add missed put_device()
  2020-07-14 19:29     ` Hans de Goede
@ 2020-07-16 16:48       ` Pierre-Louis Bossart
  0 siblings, 0 replies; 6+ messages in thread
From: Pierre-Louis Bossart @ 2020-07-16 16:48 UTC (permalink / raw)
  To: Hans de Goede, Jing Xiangfeng, cezary.rojewski, liam.r.girdwood,
	yang.jie, broonie, perex, tiwai, kuninori.morimoto.gx, paul
  Cc: alsa-devel, linux-kernel



>>>> snd_byt_cht_es8316_mc_probe() misses to call put_device() in an error
>>>> path. Add the missed function call to fix it.
>>>>
>>>> Fixes: ba49cf6f8e4a ("ASoC: Intel: bytcht_es8316: Add quirk for 
>>>> inverted jack detect")
>>>> Signed-off-by: Jing Xiangfeng <jingxiangfeng@huawei.com>
>>>
>>> Patch looks good to me:
>>>
>>> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
>>
>> Actually the existing code looks quite odd to me:
>>
>> if (cnt) {
>>      ret = device_add_properties(codec_dev, props);
>>      if (ret)
>>          return ret;
>> }
>>
>> devm_acpi_dev_add_driver_gpios(codec_dev, byt_cht_es8316_gpios);
>> priv->speaker_en_gpio =
>>      gpiod_get_index(codec_dev, "speaker-enable", 0,
>>              /* see comment in byt_cht_es8316_resume */
>>              GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_NONEXCLUSIVE);
>> put_device(codec_dev);
>>
>> if the first branch is not taken the put_device() will not be balanced.
> 
> The get_device() does not come from the device_add_properties, it comes
> from the earlier:
> 
> codec_dev = bus_find_device_by_name(&i2c_bus_type, NULL, codec_name);
> 
> call.

I probably needed more coffee when I wrote this, indeed this is fine...

Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>


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

* Re: [PATCH] ASoC: Intel: bytcht_es8316: Add missed put_device()
  2020-07-14  8:09 [PATCH] ASoC: Intel: bytcht_es8316: Add missed put_device() Jing Xiangfeng
  2020-07-14 13:33 ` Hans de Goede
@ 2020-07-16 23:57 ` Mark Brown
  1 sibling, 0 replies; 6+ messages in thread
From: Mark Brown @ 2020-07-16 23:57 UTC (permalink / raw)
  To: pierre-louis.bossart, kuninori.morimoto.gx, hdegoede, paul,
	yang.jie, liam.r.girdwood, cezary.rojewski, Jing Xiangfeng,
	tiwai, perex
  Cc: alsa-devel, linux-kernel

On Tue, 14 Jul 2020 16:09:18 +0800, Jing Xiangfeng wrote:
> snd_byt_cht_es8316_mc_probe() misses to call put_device() in an error
> path. Add the missed function call to fix it.

Applied to

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

Thanks!

[1/1] ASoC: Intel: bytcht_es8316: Add missed put_device()
      commit: b3df80ab6d147d4738be242e1c91e5fdbb6b03ef

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

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

end of thread, other threads:[~2020-07-16 23:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-14  8:09 [PATCH] ASoC: Intel: bytcht_es8316: Add missed put_device() Jing Xiangfeng
2020-07-14 13:33 ` Hans de Goede
2020-07-14 15:32   ` Pierre-Louis Bossart
2020-07-14 19:29     ` Hans de Goede
2020-07-16 16:48       ` Pierre-Louis Bossart
2020-07-16 23:57 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).