浏览代码

asoc: free backend_name memory when error happens

Free backend_name memory when error happens.

Change-Id: Ia54e5483f061ec015cc717e0b408804df58af7f0
Signed-off-by: Meng Wang <[email protected]>
Meng Wang 3 年之前
父节点
当前提交
17e29ced12
共有 1 个文件被更改,包括 14 次插入8 次删除
  1. 14 8
      asoc/msm_common.c

+ 14 - 8
asoc/msm_common.c

@@ -1102,16 +1102,20 @@ int msm_common_dai_link_init(struct snd_soc_pcm_runtime *rtd)
 	}
 
 	pdata = devm_kzalloc(dev, sizeof(struct chmap_pdata), GFP_KERNEL);
-	if (!pdata)
-		return -ENOMEM;
+	if (!pdata) {
+		ret = -ENOMEM;
+		goto free_backend;
+	}
 
 	if ((!strncmp(backend_name, "SLIM", strlen("SLIM"))) ||
 		(!strncmp(backend_name, "CODEC_DMA", strlen("CODEC_DMA")))) {
 		ctl_len = strlen(dai_link->stream_name) + 1 +
 				strlen(mixer_ctl_name) + 1;
 		mixer_str = kzalloc(ctl_len, GFP_KERNEL);
-		if (!mixer_str)
-			return -ENOMEM;
+		if (!mixer_str) {
+			ret = -ENOMEM;
+			goto free_backend;
+		}
 
 		snprintf(mixer_str, ctl_len, "%s %s", dai_link->stream_name,
 				mixer_ctl_name);
@@ -1149,14 +1153,16 @@ int msm_common_dai_link_init(struct snd_soc_pcm_runtime *rtd)
 	}
 
 free_mixer_str:
-	if (backend_name) {
-		kfree(backend_name);
-		backend_name = NULL;
-	}
 	if (mixer_str) {
 		kfree(mixer_str);
 		mixer_str = NULL;
 	}
 
+free_backend:
+	if (backend_name) {
+		kfree(backend_name);
+		backend_name = NULL;
+	}
+
 	return ret;
 }