[alsa-devel] [PATCH] ALSA: memory leak in alsaucm

Baek Chang baeksan at ccrma.stanford.edu
Tue May 3 19:47:05 CEST 2011


I was using the instructions on alsa.org, but some of the git commands were
not working on my machine, your instructions seem to work.

Thanks!

On Mon, May 2, 2011 at 5:14 PM, Lu Guanqun <guanqun.lu at intel.com> wrote:

> Hi,
>
> On Tue, May 03, 2011 at 05:56:28AM +0800, Baek Chang wrote:
> > First time sending a patch, please let me know if I am doing this
> > incorrectly.
>
> Generally, we don't send patches as attachment.
>
> As you're git, you can do three more steps.
>
> 1. commit your changes using git
>   git commit -a -s
>   when editor is invoked, you can input your reasons why this should be
>   changed.
>   the option '-s' here will add the "Signed-off-by:" line for you.
>
> 2. git format-patch -1
>   this command will generate the properly formated patch for you.
>
> 3. git send-email --to alsa-devel at alsa-project.org --cc
>   <sound-maintainters> *.patch
>   before you can use this send-email command, you need to add some
>   configuration in your .gitconfig file, consult the manual to learn more.
>
> HTH
>
> >
> > alsaucm is leaking memory whenever execute_cset() is called.
> >
> >
> > bchang at LT74002R2XXG1:~/projects/alsa-lib-git/src/ucm$ git diff
> > diff --git a/src/ucm/main.c b/src/ucm/main.c
> > index 86f29e3..f8ceeeb 100644
> > --- a/src/ucm/main.c
> > +++ b/src/ucm/main.c
> > @@ -173,7 +173,8 @@ static int execute_cset(snd_ctl_t *ctl, char *cset)
> >         pos = strrchr(cset, ' ');
> >         if (pos == NULL) {
> >                 uc_error("undefined value for cset >%s<", cset);
> > -               return -EINVAL;
> > +               err =  -EINVAL;
> > +               goto __fail;
> >         }
> >         *pos = '\0';
> >         err = snd_ctl_ascii_elem_id_parse(id, cset);
> > @@ -196,6 +197,14 @@ static int execute_cset(snd_ctl_t *ctl, char *cset)
> >         err = 0;
> >        __fail:
> >         *pos = ' ';
> > +
> > +       if (id != NULL)
> > +               free(id);
> > +       if (value != NULL)
> > +               free(value);
> > +       if (info != NULL)
> > +               free(info);
> > +
> >         return err;
> >  }
> >
> >
> >
> > Thanks
> > --
> > -baeksanchang
>
> > diff --git a/src/ucm/main.c b/src/ucm/main.c
> > index 86f29e3..f8ceeeb 100644
> > --- a/src/ucm/main.c
> > +++ b/src/ucm/main.c
> > @@ -173,7 +173,8 @@ static int execute_cset(snd_ctl_t *ctl, char *cset)
> >       pos = strrchr(cset, ' ');
> >       if (pos == NULL) {
> >               uc_error("undefined value for cset >%s<", cset);
> > -             return -EINVAL;
> > +             err =  -EINVAL;
> > +             goto __fail;
> >       }
> >       *pos = '\0';
> >       err = snd_ctl_ascii_elem_id_parse(id, cset);
> > @@ -196,6 +197,14 @@ static int execute_cset(snd_ctl_t *ctl, char *cset)
> >       err = 0;
> >        __fail:
> >       *pos = ' ';
> > +
> > +     if (id != NULL)
> > +             free(id);
> > +     if (value != NULL)
> > +             free(value);
> > +     if (info != NULL)
> > +             free(info);
> > +
> >       return err;
> >  }
> >
>
> > _______________________________________________
> > Alsa-devel mailing list
> > Alsa-devel at alsa-project.org
> > http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>
>
> --
> guanqun
>



-- 
-baeksanchang


More information about the Alsa-devel mailing list