[alsa-devel] [PATCH] coverity fix in alsa-libs

Takashi Iwai tiwai at suse.de
Thu Sep 18 17:25:46 CEST 2014


At Thu, 18 Sep 2014 11:15:50 +0000 (GMT),
Renu Tyagi wrote:
> 
> 
> Hi,
> Bug type : missing freeing resources before returning in case of errors
> Files changed : sbase.c  pcm_file.c
> PFA patch
> 
> -------------------------------------------------------------------
> From f201df1f5c5d129f21c663c81fdb495d9a3ca51e Mon Sep 17 00:00:00 2001
> From: renu tyagi <renu.tyagi at samsung.com>
> 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

> Signed-off-by: renu tyagi <renu.tyagi at samsung.com>
> ---
>  modules/mixer/simple/sbase.c |    1 +
>  src/pcm/pcm_file.c           |    2 ++
>  2 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/modules/mixer/simple/sbase.c b/modules/mixer/simple/sbase.c
> index 97feee8..bb2f59d 100644
> --- a/modules/mixer/simple/sbase.c
> +++ b/modules/mixer/simple/sbase.c
> @@ -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;
> diff --git a/src/pcm/pcm_file.c b/src/pcm/pcm_file.c
> index a0b8bf4..f6d222f 100644
> --- a/src/pcm/pcm_file.c
> +++ b/src/pcm/pcm_file.c
> @@ -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
> 


More information about the Alsa-devel mailing list