Skip to contentSkip to conversation

coverity fix in alsa-libs

PATCH Takashi Iwai 1 participant 1 message Sep 18, 2014 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

At Thu, 18 Sep 2014 11:15:50 +0000 (GMT),

Quoted 7 lines · Renu Tyagi

Hi,
Bug type : missing freeing resources before returning in case of errors Files changed : sbase.c pcm_file.c
PFA patch

Quoted 5 lines

-------------------------------------------------------------------
From f201df1f5c5d129f21c663c81fdb495d9a3ca51e Mon Sep 17 00:00:00 2001
From: renu tyagi <[email protected]>
Date: Thu, 18 Sep 2014 16:17:55 +0530
Subject: [PATCH 2/8] [sbase , pcm_file] : freeing resources before returning in case of errors

Please just send the patch as is. We don't need any foreword. Also, if the changes cover over different areas, split the patch.

thanks,

Takashi

Quoted 44 lines
---
 modules/mixer/simple/sbase.c |    1 +
 src/pcm/pcm_file.c           |    2 ++
 2 files changed, 3 insertions(+), 0 deletions(-)
modules/mixer/simple/sbase.c +1 -0
index 97feee8..bb2f59d 100644
@@ -377,6 +377,7 @@ static int simple_event_add1(snd_mixer_class_t *class,
                if (ctype != SND_CTL_ELEM_TYPE_BOOLEAN) {
                      __invalid_type:
                        snd_mixer_selem_id_free(id);
+                       free(hsimple);
                        return -EINVAL;
                }
                break;
src/pcm/pcm_file.c +2 -1
index a0b8bf4..f6d222f 100644
@@ -758,6 +758,7 @@ int snd_pcm_file_open(snd_pcm_t **pcmp, const char *name,
                ifd = open(ifname, O_RDONLY);   /* TODO: mind blocking mode */
                if (ifd < 0) {
                        SYSERR("open %s for reading failed", ifname);
+                       free(file->fname);
                        free(file);
                        return -errno;
                }
@@ -772,6 +773,7 @@ int snd_pcm_file_open(snd_pcm_t **pcmp, const char *name,
        err = snd_pcm_new(&pcm, SND_PCM_TYPE_FILE, name, slave->stream, slave->mode);
        if (err < 0) {
                free(file->fname);
+               free(file->ifname);
                free(file);
                return err;
        }
--

1.7.1

Thanks
Renu Tyagi