Skip to contentSkip to conversation

control_hw: fix potential memory leak

PATCH Applied [email protected] 2 participants 2 messages Jan 21, 2014 – Jan 22, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 control_hw: fix potential memory leak

From: Ivan Sorokin <[email protected]>

src/control/control_hw.c +3 -1
index 148097f..dfc9dcd 100644
@@ -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);
Signature · 1 line
1.8.1.2
Applied
#1 lore raw

At Wed, 22 Jan 2014 00:12:50 +0400,

Quoted 5 lines · [email protected] wrote:

From: Ivan Sorokin <[email protected]>

Thanks, applied.

Takashi

Quoted 20 lines
src/control/control_hw.c +3 -1
index 148097f..dfc9dcd 100644
@@ -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);
Signature · 1 line
1.8.1.2