diff mbox series

[1/2] ASoC: topology: free stream_name of dai_drv

Message ID 20190305155753.10362-1-yung-chuan.liao@linux.intel.com (mailing list archive)
State Accepted
Commit 7b6f68a4df4df3a58e854d24da991640bd4d9590
Headers show
Series [1/2] ASoC: topology: free stream_name of dai_drv | expand

Commit Message

Bard Liao March 5, 2019, 3:57 p.m. UTC
The stream_name is allocated by kstrdup. We have to free it when the
dai is removed or return from error.

Signed-off-by: Bard liao <yung-chuan.liao@linux.intel.com>
---
 sound/soc/soc-topology.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Pierre-Louis Bossart March 6, 2019, 5:56 p.m. UTC | #1
On 3/5/19 9:57 AM, Bard liao wrote:
> The stream_name is allocated by kstrdup. We have to free it when the
> dai is removed or return from error.
>
> Signed-off-by: Bard liao <yung-chuan.liao@linux.intel.com>

I reviewed and verified the flows, so both patch1 and 2:

Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

Thanks!

> ---
>   sound/soc/soc-topology.c | 5 +++++
>   1 file changed, 5 insertions(+)
>
> diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
> index 25fca7055464..4e05ef001e04 100644
> --- a/sound/soc/soc-topology.c
> +++ b/sound/soc/soc-topology.c
> @@ -535,6 +535,8 @@ static void remove_dai(struct snd_soc_component *comp,
>   		if (dai->driver == dai_drv)
>   			dai->driver = NULL;
>   
> +	kfree(dai_drv->playback.stream_name);
> +	kfree(dai_drv->capture.stream_name);
>   	kfree(dai_drv->name);
>   	list_del(&dobj->list);
>   	kfree(dai_drv);
> @@ -1806,6 +1808,9 @@ static int soc_tplg_dai_create(struct soc_tplg *tplg,
>   	ret = soc_tplg_dai_load(tplg, dai_drv, pcm, NULL);
>   	if (ret < 0) {
>   		dev_err(tplg->comp->dev, "ASoC: DAI loading failed\n");
> +		kfree(dai_drv->playback.stream_name);
> +		kfree(dai_drv->capture.stream_name);
> +		kfree(dai_drv->name);
>   		kfree(dai_drv);
>   		return ret;
>   	}
diff mbox series

Patch

diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index 25fca7055464..4e05ef001e04 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -535,6 +535,8 @@  static void remove_dai(struct snd_soc_component *comp,
 		if (dai->driver == dai_drv)
 			dai->driver = NULL;
 
+	kfree(dai_drv->playback.stream_name);
+	kfree(dai_drv->capture.stream_name);
 	kfree(dai_drv->name);
 	list_del(&dobj->list);
 	kfree(dai_drv);
@@ -1806,6 +1808,9 @@  static int soc_tplg_dai_create(struct soc_tplg *tplg,
 	ret = soc_tplg_dai_load(tplg, dai_drv, pcm, NULL);
 	if (ret < 0) {
 		dev_err(tplg->comp->dev, "ASoC: DAI loading failed\n");
+		kfree(dai_drv->playback.stream_name);
+		kfree(dai_drv->capture.stream_name);
+		kfree(dai_drv->name);
 		kfree(dai_drv);
 		return ret;
 	}