Skip to contentSkip to conversation

ASoC: Intel: bytcht_es8316: Add missed put_device()

PATCH In review Jing Xiangfeng 4 participants 6 messages Jul 14, 2020 – Jul 16, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: Intel: bytcht_es8316: Add missed put_device()

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")
---
 sound/soc/intel/boards/bytcht_es8316.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/intel/boards/bytcht_es8316.c +3 -1
index 9e5fc9430628..ecbc58e8a37f 100644
@@ -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);
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw

Hi,

Quoted 5 lines · Jing Xiangfeng

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")

Patch looks good to me:

Regards,

Hans

Quoted 21 lines
---
  sound/soc/intel/boards/bytcht_es8316.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/intel/boards/bytcht_es8316.c +3 -1
index 9e5fc9430628..ecbc58e8a37f 100644
@@ -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 lore raw
Quoted 6 lines · Hans de Goede

Hi,

Quoted 3 lines · Jing Xiangfeng

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

Quoted 6 lines
Quoted 2 lines
Fixes ba49cf6f8e4a ("ASoC: Intel: bytcht_es8316: Add quirk for inverted jack detect")

Patch looks good to me:

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); */

Quoted 27 lines

Regards,

Hans

Quoted 20 lines

---
  sound/soc/intel/boards/bytcht_es8316.c | 4 +++-

  1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/intel/boards/bytcht_es8316.c +3 -1
index 9e5fc9430628..ecbc58e8a37f 100644
@@ -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);
 
#3 lore raw

Hi,

Quoted 24 lines · Pierre-Louis Bossart
Quoted 6 lines · Hans de Goede

Hi,

Quoted 3 lines · Jing Xiangfeng

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

Quoted 6 lines
Quoted 2 lines
Fixes ba49cf6f8e4a ("ASoC: Intel: bytcht_es8316: Add quirk for inverted jack detect")

Patch looks good to me:

Actually the existing code looks quite odd to me:

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

Quoted 8 lines

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

Quoted 44 lines

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); */

Quoted 26 lines

Regards,

Hans

Quoted 19 lines

---
  sound/soc/intel/boards/bytcht_es8316.c | 4 +++-

  1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/intel/boards/bytcht_es8316.c +3 -1
index 9e5fc9430628..ecbc58e8a37f 100644
@@ -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);
 
#4 lore raw
Quoted 27 lines
Quoted 27 lines
Quoted 11 lines
Quoted 7 lines

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")

Patch looks good to me:

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);

Quoted 8 lines
Quoted 1 line

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...

maintainer
#5 lore raw
In reply to Jing Xiangfeng
Quoted 2 lines · Jing Xiangfeng

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