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

Takashi Iwai tiwai at suse.de
Wed May 4 11:53:06 CEST 2011


At Wed,  4 May 2011 12:46:00 +0300,
sudarshan.bisht at nokia.com wrote:
> 
> diff --git a/src/conf.c b/src/conf.c
> index ddefff6..842e5e3 100644
> --- a/src/conf.c
> +++ b/src/conf.c
> @@ -638,6 +638,7 @@ static int get_char_skip_comments(input_t *input)
>  			fd = malloc(sizeof(*fd));
>  			if (!fd) {
>  				free(str);
> +				snd_input_close(in);
>  				return -ENOMEM;
>  			}
>  			fd->name = str;

I don't think this is correct.  The close should be never called
during the operation in the library function.


> diff --git a/src/pcm/pcm_file.c b/src/pcm/pcm_file.c
> index bfa1cc8..adba7c0 100644
> --- a/src/pcm/pcm_file.c
> +++ b/src/pcm/pcm_file.c
> @@ -226,7 +226,9 @@ static int snd_pcm_file_open_output_file(snd_pcm_file_t *file)
>  					file->final_fname);
>  			return -errno;
>  		}
> -		fd = fileno(pipe);
> +		fd = dup(fileno(pipe));
> +		if (fd >= 0)
> +			fclose(pipe);

The error handling is missing?


thanks,

Takashi


More information about the Alsa-devel mailing list