All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH - my module 1/1] control_hw: fix potential memory leak
@ 2014-01-21 20:12 vanyacpp
  2014-01-22  6:41 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: vanyacpp @ 2014-01-21 20:12 UTC (permalink / raw)
  To: patch; +Cc: Ivan Sorokin, alsa-devel

From: Ivan Sorokin <vanyacpp@gmail.com>


Signed-off-by: Ivan Sorokin <vanyacpp@gmail.com>

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH - my module 1/1] control_hw: fix potential memory leak
  2014-01-21 20:12 [PATCH - my module 1/1] control_hw: fix potential memory leak vanyacpp
@ 2014-01-22  6:41 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2014-01-22  6:41 UTC (permalink / raw)
  To: vanyacpp; +Cc: alsa-devel

At Wed, 22 Jan 2014 00:12:50 +0400,
vanyacpp@gmail.com wrote:
> 
> From: Ivan Sorokin <vanyacpp@gmail.com>
> 
> 
> Signed-off-by: Ivan Sorokin <vanyacpp@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
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-01-22  6:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-21 20:12 [PATCH - my module 1/1] control_hw: fix potential memory leak vanyacpp
2014-01-22  6:41 ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.