Skip to content

Commit d784fc8

Browse files
andy-shevbroonie
authored andcommitted
ASoC: amd: acp-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: 02527c3 ("ASoC: amd: add Machine driver for Jadeite platform") Signed-off-by: Andy Shevchenko <[email protected]> Acked-by: Vijendar Mukunda <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 7fd26a2 commit d784fc8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

sound/soc/amd/acp-es8336.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,11 @@ static int st_es8336_late_probe(struct snd_soc_card *card)
198198
int ret;
199199

200200
adev = acpi_dev_get_first_match_dev("ESSX8336", NULL, -1);
201-
if (adev)
202-
put_device(&adev->dev);
201+
if (!adev)
202+
return -ENODEV;
203+
203204
codec_dev = acpi_get_first_physical_node(adev);
205+
acpi_dev_put(adev);
204206
if (!codec_dev)
205207
dev_err(card->dev, "can not find codec dev\n");
206208

0 commit comments

Comments
 (0)