From 336dc58beba0ca7cf5650dc12ed3eb72d61ac6d3 Mon Sep 17 00:00:00 2001 From: Ivan Sorokin Date: Wed, 22 Jan 2014 00:12:50 +0400 Subject: [PATCH] control_hw: fix potential memory leak Signed-off-by: Ivan Sorokin Signed-off-by: Takashi Iwai --- src/control/control_hw.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/control/control_hw.c b/src/control/control_hw.c index 148097facd90..dfc9dcd51e20 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.9.0