Skip to content

Commit 64e57b2

Browse files
andy-shevbroonie
authored andcommitted
ASoC: Intel: sof_es8336: Drop reference count of ACPI device after use
Theoretically the device might gone if its reference count drops to 0. This might be the case when we try to find the first physical node of the ACPI device. We need to keep reference to it until we get a result of the above mentioned call. Refactor the code to drop the reference count at the correct place. While at it, move to acpi_dev_put() as symmetrical call to the acpi_dev_get_first_match_dev(). Fixes: a164137 ("ASoC: Intel: add machine driver for SOF+ES8336") Signed-off-by: Andy Shevchenko <[email protected]> Acked-by: Pierre-Louis Bossart <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent c8aa49a commit 64e57b2

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

sound/soc/intel/boards/sof_es8336.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,6 @@ static int sof_es8336_probe(struct platform_device *pdev)
681681
if (adev) {
682682
snprintf(codec_name, sizeof(codec_name),
683683
"i2c-%s", acpi_dev_name(adev));
684-
put_device(&adev->dev);
685684
dai_links[0].codecs->name = codec_name;
686685

687686
/* also fixup codec dai name if relevant */
@@ -692,16 +691,19 @@ static int sof_es8336_probe(struct platform_device *pdev)
692691
return -ENXIO;
693692
}
694693

695-
ret = snd_soc_fixup_dai_links_platform_name(&sof_es8336_card,
696-
mach->mach_params.platform);
697-
if (ret)
698-
return ret;
699-
700694
codec_dev = acpi_get_first_physical_node(adev);
695+
acpi_dev_put(adev);
701696
if (!codec_dev)
702697
return -EPROBE_DEFER;
703698
priv->codec_dev = get_device(codec_dev);
704699

700+
ret = snd_soc_fixup_dai_links_platform_name(&sof_es8336_card,
701+
mach->mach_params.platform);
702+
if (ret) {
703+
put_device(codec_dev);
704+
return ret;
705+
}
706+
705707
if (quirk & SOF_ES8336_JD_INVERTED)
706708
props[cnt++] = PROPERTY_ENTRY_BOOL("everest,jack-detect-inverted");
707709

0 commit comments

Comments
 (0)