ASoC: wm_adsp: Fix memory leak in wm_adsp_setup_algs
authorJS Park <aitdark.park@samsung.com>
Tue, 18 Nov 2014 16:07:22 +0000 (16:07 +0000)
committerMark Brown <broonie@kernel.org>
Tue, 18 Nov 2014 16:21:15 +0000 (16:21 +0000)
Signed-off-by: JS Park <aitdark.park@samsung.com>
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/wm_adsp.c

index 0a08ef5e27c8dce83be3bc5404b7132dd048f890..6a2a03570977c36fa68a937cee9a94683759121e 100644 (file)
@@ -1053,8 +1053,10 @@ static int wm_adsp_setup_algs(struct wm_adsp *dsp)
                                  be32_to_cpu(adsp1_alg[i].zm));
 
                        region = kzalloc(sizeof(*region), GFP_KERNEL);
-                       if (!region)
-                               return -ENOMEM;
+                       if (!region) {
+                               ret = -ENOMEM;
+                               goto out;
+                       }
                        region->type = WMFW_ADSP1_DM;
                        region->alg = be32_to_cpu(adsp1_alg[i].alg.id);
                        region->base = be32_to_cpu(adsp1_alg[i].dm);
@@ -1071,8 +1073,10 @@ static int wm_adsp_setup_algs(struct wm_adsp *dsp)
                        }
 
                        region = kzalloc(sizeof(*region), GFP_KERNEL);
-                       if (!region)
-                               return -ENOMEM;
+                       if (!region) {
+                               ret = -ENOMEM;
+                               goto out;
+                       }
                        region->type = WMFW_ADSP1_ZM;
                        region->alg = be32_to_cpu(adsp1_alg[i].alg.id);
                        region->base = be32_to_cpu(adsp1_alg[i].zm);
@@ -1101,8 +1105,10 @@ static int wm_adsp_setup_algs(struct wm_adsp *dsp)
                                  be32_to_cpu(adsp2_alg[i].zm));
 
                        region = kzalloc(sizeof(*region), GFP_KERNEL);
-                       if (!region)
-                               return -ENOMEM;
+                       if (!region) {
+                               ret = -ENOMEM;
+                               goto out;
+                       }
                        region->type = WMFW_ADSP2_XM;
                        region->alg = be32_to_cpu(adsp2_alg[i].alg.id);
                        region->base = be32_to_cpu(adsp2_alg[i].xm);
@@ -1119,8 +1125,10 @@ static int wm_adsp_setup_algs(struct wm_adsp *dsp)
                        }
 
                        region = kzalloc(sizeof(*region), GFP_KERNEL);
-                       if (!region)
-                               return -ENOMEM;
+                       if (!region) {
+                               ret = -ENOMEM;
+                               goto out;
+                       }
                        region->type = WMFW_ADSP2_YM;
                        region->alg = be32_to_cpu(adsp2_alg[i].alg.id);
                        region->base = be32_to_cpu(adsp2_alg[i].ym);
@@ -1137,8 +1145,10 @@ static int wm_adsp_setup_algs(struct wm_adsp *dsp)
                        }
 
                        region = kzalloc(sizeof(*region), GFP_KERNEL);
-                       if (!region)
-                               return -ENOMEM;
+                       if (!region) {
+                               ret = -ENOMEM;
+                               goto out;
+                       }
                        region->type = WMFW_ADSP2_ZM;
                        region->alg = be32_to_cpu(adsp2_alg[i].alg.id);
                        region->base = be32_to_cpu(adsp2_alg[i].zm);