[pulseaudio-discuss] [PATCH 02/13] modules: Fix resource leak in alsa-card

Peter Meerwald pmeerw at pmeerw.net
Mon Dec 16 09:20:04 PST 2013


From: Peter Meerwald <p.meerwald at bct-electronic.com>

https://scan7.coverity.com:8443/reports.htm#v10205/p10016/fileInstanceId=8851&defectInstanceId=3725&mergedDefectId=591261

Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>
---
 src/modules/alsa/module-alsa-card.c |   15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c
index be982ed..1a823d7 100644
--- a/src/modules/alsa/module-alsa-card.c
+++ b/src/modules/alsa/module-alsa-card.c
@@ -204,6 +204,7 @@ static int card_set_profile(pa_card *c, pa_card_profile *new_profile) {
     uint32_t idx;
     pa_alsa_mapping *am;
     pa_queue *sink_inputs = NULL, *source_outputs = NULL;
+    int ret = 0;
 
     pa_assert(c);
     pa_assert(new_profile);
@@ -245,8 +246,10 @@ static int card_set_profile(pa_card *c, pa_card_profile *new_profile) {
     /* if UCM is available for this card then update the verb */
     if (u->use_ucm) {
         if (pa_alsa_ucm_set_profile(&u->ucm, nd->profile ? nd->profile->name : NULL,
-                    od->profile ? od->profile->name : NULL) < 0)
-            return -1;
+                    od->profile ? od->profile->name : NULL) < 0) {
+            ret = -1;
+            goto finish;
+        }
     }
 
     if (nd->profile && nd->profile->output_mappings)
@@ -273,13 +276,14 @@ static int card_set_profile(pa_card *c, pa_card_profile *new_profile) {
             }
         }
 
+finish:
     if (sink_inputs)
         pa_sink_move_all_fail(sink_inputs);
 
     if (source_outputs)
         pa_source_move_all_fail(source_outputs);
 
-    return 0;
+    return ret;
 }
 
 static void init_profile(struct userdata *u) {
@@ -764,12 +768,17 @@ int pa__init(pa_module *m) {
                     "is abused (i.e. fixes are not pushed to ALSA), the decibel fix feature may be removed in some future "
                     "PulseAudio version.", u->card->name);
 
+    pa_modargs_free(ma);
+
     return 0;
 
 fail:
     if (reserve)
         pa_reserve_wrapper_unref(reserve);
 
+    if (ma)
+        pa_modargs_free(ma);
+
     pa__done(m);
 
     return -1;
-- 
1.7.9.5



More information about the pulseaudio-discuss mailing list