Skip to content

Commit

Permalink
ASoC: hdac_hda: fix memleak with regmap not freed on remove
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
plbossart authored and broonie committed Jun 17, 2020
1 parent ed1220d commit a94eacc
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions sound/soc/codecs/hdac_hda.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,21 +441,21 @@ static int hdac_hda_codec_probe(struct snd_soc_component *component)
ret = snd_hda_codec_set_name(hcodec, hcodec->preset->name);
if (ret < 0) {
dev_err(&hdev->dev, "name failed %s\n", hcodec->preset->name);
goto error;
goto error_pm;
}

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

patch = (hda_codec_patch_t)hcodec->preset->driver_data;
if (patch) {
ret = patch(hcodec);
if (ret < 0) {
dev_err(&hdev->dev, "patch failed %d\n", ret);
goto error;
goto error_regmap;
}
} else {
dev_dbg(&hdev->dev, "no patch file found\n");
Expand All @@ -467,7 +467,7 @@ static int hdac_hda_codec_probe(struct snd_soc_component *component)
ret = snd_hda_codec_parse_pcms(hcodec);
if (ret < 0) {
dev_err(&hdev->dev, "unable to map pcms to dai %d\n", ret);
goto error;
goto error_regmap;
}

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

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

return 0;

error:
error_regmap:
snd_hdac_regmap_exit(hdev);
error_pm:
pm_runtime_put(&hdev->dev);
error_no_pm:
snd_hdac_ext_bus_link_put(hdev->bus, hlink);
Expand All @@ -518,6 +520,8 @@ static void hdac_hda_codec_remove(struct snd_soc_component *component)

pm_runtime_disable(&hdev->dev);
snd_hdac_ext_bus_link_put(hdev->bus, hlink);

snd_hdac_regmap_exit(hdev);
}

static const struct snd_soc_dapm_route hdac_hda_dapm_routes[] = {
Expand Down

0 comments on commit a94eacc

Please sign in to comment.