> imx_card_parse_of() takes references on the CPU and codec device nodes
> with snd_soc_of_get_dlc() and snd_soc_of_get_dai_link_codecs() and
> stores them in the link's component arrays. The driver has no remove
> callback and the ASoC core does not drop these references when the card
> is unregistered, so unbinding the platform device or unloading the
> module leaks one device node reference per CPU and codec.
> +static void imx_card_remove(struct platform_device *pdev)
> +{
> + struct snd_soc_card *card = dev_get_drvdata(&pdev->dev);
> + struct snd_soc_dai_link *link;
> + int i;
> +
> + for_each_card_prelinks(card, i, link) {
> + snd_soc_of_put_dai_link_cpus(link);
> + snd_soc_of_put_dai_link_codecs(link);
> + }
> +}
> +
> static const struct of_device_id imx_card_dt_ids[] = {
> { .compatible = "fsl,imx-audio-card", },
> { },
> @@ -940,6 +952,7 @@ static struct platform_driver imx_card_driver = {
> .of_match_table = imx_card_dt_ids,
> },
> .probe = imx_card_probe,
> + .remove = imx_card_remove,
> };
This only runs on remove so we've got the same issue if anything goes
wrong during probe (eg, deferral).
--
Mark Brown <[email protected]>