Skip to content

Commit a94eacc

Browse files
plbossartbroonie
authored andcommitted
ASoC: hdac_hda: fix memleak with regmap not freed on remove
kmemleak throws error reports on module load/unload tests, add snd_hdac_regmap_exit() in .remove(). While we are at it, also fix the error handling flow in .probe() to use snd_hdac_regmap_exit() if needed. Signed-off-by: Pierre-Louis Bossart <[email protected]> Reviewed-by: Daniel Baluta <[email protected]> Reviewed-by: Kai Vehmanen <[email protected]> Reviewed-by: Rander Wang <[email protected]> Reviewed-by: Guennadi Liakhovetski <[email protected]> Reviewed-by: Bard Liao <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent ed1220d commit a94eacc

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

sound/soc/codecs/hdac_hda.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -441,21 +441,21 @@ static int hdac_hda_codec_probe(struct snd_soc_component *component)
441441
ret = snd_hda_codec_set_name(hcodec, hcodec->preset->name);
442442
if (ret < 0) {
443443
dev_err(&hdev->dev, "name failed %s\n", hcodec->preset->name);
444-
goto error;
444+
goto error_pm;
445445
}
446446

447447
ret = snd_hdac_regmap_init(&hcodec->core);
448448
if (ret < 0) {
449449
dev_err(&hdev->dev, "regmap init failed\n");
450-
goto error;
450+
goto error_pm;
451451
}
452452

453453
patch = (hda_codec_patch_t)hcodec->preset->driver_data;
454454
if (patch) {
455455
ret = patch(hcodec);
456456
if (ret < 0) {
457457
dev_err(&hdev->dev, "patch failed %d\n", ret);
458-
goto error;
458+
goto error_regmap;
459459
}
460460
} else {
461461
dev_dbg(&hdev->dev, "no patch file found\n");
@@ -467,7 +467,7 @@ static int hdac_hda_codec_probe(struct snd_soc_component *component)
467467
ret = snd_hda_codec_parse_pcms(hcodec);
468468
if (ret < 0) {
469469
dev_err(&hdev->dev, "unable to map pcms to dai %d\n", ret);
470-
goto error;
470+
goto error_regmap;
471471
}
472472

473473
/* HDMI controls need to be created in machine drivers */
@@ -476,7 +476,7 @@ static int hdac_hda_codec_probe(struct snd_soc_component *component)
476476
if (ret < 0) {
477477
dev_err(&hdev->dev, "unable to create controls %d\n",
478478
ret);
479-
goto error;
479+
goto error_regmap;
480480
}
481481
}
482482

@@ -496,7 +496,9 @@ static int hdac_hda_codec_probe(struct snd_soc_component *component)
496496

497497
return 0;
498498

499-
error:
499+
error_regmap:
500+
snd_hdac_regmap_exit(hdev);
501+
error_pm:
500502
pm_runtime_put(&hdev->dev);
501503
error_no_pm:
502504
snd_hdac_ext_bus_link_put(hdev->bus, hlink);
@@ -518,6 +520,8 @@ static void hdac_hda_codec_remove(struct snd_soc_component *component)
518520

519521
pm_runtime_disable(&hdev->dev);
520522
snd_hdac_ext_bus_link_put(hdev->bus, hlink);
523+
524+
snd_hdac_regmap_exit(hdev);
521525
}
522526

523527
static const struct snd_soc_dapm_route hdac_hda_dapm_routes[] = {

0 commit comments

Comments
 (0)