[alsa-devel] [PATCH - my module 1/1] control_hw: fix potential memory leak

Takashi Iwai tiwai at suse.de
Wed Jan 22 07:41:29 CET 2014


At Wed, 22 Jan 2014 00:12:50 +0400,
vanyacpp at gmail.com wrote:
> 
> From: Ivan Sorokin <vanyacpp at gmail.com>
> 
> 
> Signed-off-by: Ivan Sorokin <vanyacpp at gmail.com>

Thanks, applied.


Takashi

> 
> diff --git a/src/control/control_hw.c b/src/control/control_hw.c
> index 148097f..dfc9dcd 100644
> --- a/src/control/control_hw.c
> +++ b/src/control/control_hw.c
> @@ -240,8 +240,10 @@ static int snd_ctl_hw_elem_tlv(snd_ctl_t *handle, int op_flag,
>  		return -errno;
>  	}
>  	if (op_flag == 0) {
> -		if (xtlv->tlv[1] + 2 * sizeof(unsigned int) > tlv_size)
> +		if (xtlv->tlv[1] + 2 * sizeof(unsigned int) > tlv_size) {
> +			free(xtlv);
>  			return -EFAULT;
> +		}
>  		memcpy(tlv, xtlv->tlv, xtlv->tlv[1] + 2 * sizeof(unsigned int));
>  	}
>  	free(xtlv);
> -- 
> 1.8.1.2
> 


More information about the Alsa-devel mailing list