浏览代码

ASoC: topology: fix some tiny memory leaks

These tiny memory leaks don't have a huge real life impact but they
cause static checker warnings so let's fix them.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Dan Carpenter 7 年之前
父节点
当前提交
65030ff305
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6 2
      sound/soc/soc-topology.c

+ 6 - 2
sound/soc/soc-topology.c

@@ -1325,8 +1325,10 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_denum_create(
 			ec->hdr.name);
 			ec->hdr.name);
 
 
 		kc[i].name = kstrdup(ec->hdr.name, GFP_KERNEL);
 		kc[i].name = kstrdup(ec->hdr.name, GFP_KERNEL);
-		if (kc[i].name == NULL)
+		if (kc[i].name == NULL) {
+			kfree(se);
 			goto err_se;
 			goto err_se;
+		}
 		kc[i].private_value = (long)se;
 		kc[i].private_value = (long)se;
 		kc[i].iface = SNDRV_CTL_ELEM_IFACE_MIXER;
 		kc[i].iface = SNDRV_CTL_ELEM_IFACE_MIXER;
 		kc[i].access = ec->hdr.access;
 		kc[i].access = ec->hdr.access;
@@ -1442,8 +1444,10 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_dbytes_create(
 			be->hdr.name, be->hdr.access);
 			be->hdr.name, be->hdr.access);
 
 
 		kc[i].name = kstrdup(be->hdr.name, GFP_KERNEL);
 		kc[i].name = kstrdup(be->hdr.name, GFP_KERNEL);
-		if (kc[i].name == NULL)
+		if (kc[i].name == NULL) {
+			kfree(sbe);
 			goto err;
 			goto err;
+		}
 		kc[i].private_value = (long)sbe;
 		kc[i].private_value = (long)sbe;
 		kc[i].iface = SNDRV_CTL_ELEM_IFACE_MIXER;
 		kc[i].iface = SNDRV_CTL_ELEM_IFACE_MIXER;
 		kc[i].access = be->hdr.access;
 		kc[i].access = be->hdr.access;