Skip to contentSkip to conversation

Netfilter: SNMP NAT helper: fix memleak snmp_object_decode

PATCH In review Chris Wright 2 participants 2 messages May 22, 2006 – May 23, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Netfilter: SNMP NAT helper: fix memleak snmp_object_decode

If kmalloc fails, error path leaks data allocated from asn1_oid_decode().

---

 net/ipv4/netfilter/ip_nat_snmp_basic.c |    1 +
 1 file changed, 1 insertion(+)
net/ipv4/netfilter/ip_nat_snmp_basic.c +1 -0
@@ -768,6 +768,7 @@ static unsigned char snmp_object_decode(
 			len *= sizeof(unsigned long);
 			*obj = kmalloc(sizeof(struct snmp_object) + len, GFP_ATOMIC);
 			if (*obj == NULL) {
+				kfree(lp);
 				kfree(id);
 				if (net_ratelimit())
 					printk("OOM in bsalg (%d)\n", __LINE__);
#1 lore raw
Quoted 1 line · Chris Wright

If kmalloc fails, error path leaks data allocated from asn1_oid_decode().

Thanks Chris, applied. "len" can't exceed the real packets length, so I don't think this can really be triggered remotely. Feel free to add to -stable though.