[alsa-devel] [PATCH] alsa-lib: fixed coverity reported issues under "USE_AFTER_FREE" checker.

Sudarshan Bisht sudarshan.bisht at nokia.com
Thu Mar 17 14:33:47 CET 2011


On Thu, 2011-03-17 at 12:22 +0100, ext Clemens Ladisch wrote:
> sudarshan.bisht at nokia.com wrote:
> > --- a/src/control/control_hw.c
> > +++ b/src/control/control_hw.c
> > @@ -414,6 +414,7 @@ int snd_ctl_hw_open(snd_ctl_t **handle, const char *name, int card, int mode)
> >  	if (err < 0) {
> >  		close(fd);
> >  		free(hw);
> > +		hw = NULL;
> >  	}
> 
> In this place, it's just a "return err" that is missing.
Ok.
> 
> > --- a/src/mixer/mixer.c
> > +++ b/src/mixer/mixer.c
> > @@ -205,7 +205,7 @@ int snd_mixer_attach(snd_mixer_t *mixer, const char *name)
> >  		return err;
> >  	err = snd_mixer_attach_hctl(mixer, hctl);
> >  	if (err < 0) {
> > -		snd_hctl_close(hctl);
> > +		/* ideally hctl should be freed here, but it's taken care in snd_mixer_attach_hctl*/	
> >  		return err;
> >  	}
> 
> If the calloc() in snd_mixer_attach_hctl() fails, hctl is not freed.
> The bug is the inconsistent error handling cleanup in
> snd_mixer_attach_hctl(); I think it shouldn't free its hctl in any case.
Ok, I will remove freeing of hctl from snd_mixer_attach_hctl().
> 
> 
> Regards,
> Clemens


Br,
Sudarshan Bisht



More information about the Alsa-devel mailing list