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

Takashi Iwai tiwai at suse.de
Wed May 4 11:57:10 CEST 2011


At Wed,  4 May 2011 12:46:01 +0300,
sudarshan.bisht at nokia.com wrote:
> 
> From: Sudarshan Bisht <sudarshan.bisht at nokia.com>
> 
> Coverity Static Analysis helps developers find hard-to-spot,
> yet potentially crash-causing defects early in the development phase,
> reducing the cost,time, and risk of software errors.
> 
> This patch has fixes for 1) a junk assignment and 2) memory freed at wrong location.
> 
> ---
>  modules/mixer/simple/python.c |    1 +
>  src/control/control_hw.c      |    1 +
>  src/mixer/mixer.c             |    1 -
>  3 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/modules/mixer/simple/python.c b/modules/mixer/simple/python.c
> index c822c52..784d9a0 100644
> --- a/modules/mixer/simple/python.c
> +++ b/modules/mixer/simple/python.c
> @@ -663,6 +663,7 @@ pymixer_attach_hctl(struct pymixer *pymixer, PyObject *args)
>  		return NULL;
>  	err = snd_mixer_attach_hctl(pymixer->mixer, hctl);
>  	if (err < 0) {
> +		snd_hctl_close(hctl);
>  		PyErr_Format(PyExc_RuntimeError, "Cannot attach hctl: %s", snd_strerror(err));
>  		return NULL;
>  	}

This doesn't look good.
We did close mistakenly in snd_mixer_attach_hctl() in the error case,
and it's fixed by your patch.  But this behavior shouldn't be inherited.


thanks,

Takashi


More information about the Alsa-devel mailing list