Subject: [PATCH]: Fix memory leak in ah6.c

From: Patrick McHardy <[email-masked]>
Date: Fri, 28 May 2004 12:50:29 +0200

Hi Dave,

this patch fixes a memory leak in ah6.c. iph is not freed when
ipv6_clear_mutable_options fails.

Regards
Patrick
# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2004/05/28 12:21:37+02:00 [email-masked] 
#   [IPSEC]: Fix memory leak in ah6.c
# 
# net/ipv6/ah6.c
#   2004/05/28 12:21:29+02:00 [email-masked] +3 -1
#   [IPSEC]: Fix memory leak in ah6.c
# 
diff -Nru a/net/ipv6/ah6.c b/net/ipv6/ah6.c
--- a/net/ipv6/ah6.c	2004-05-28 12:34:25 +02:00
+++ b/net/ipv6/ah6.c	2004-05-28 12:34:25 +02:00
@@ -190,7 +190,7 @@
 		memcpy(skb->nh.ipv6h, iph, hdr_len);
 		nexthdr = ipv6_clear_mutable_options(skb, &nh_offset, XFRM_POLICY_OUT);
 		if (nexthdr == 0)
-			goto error;
+			goto error_free_iph;
 
 		skb->nh.raw[nh_offset] = IPPROTO_AH;
 		skb->nh.ipv6h->payload_len = htons(skb->len - sizeof(struct ipv6hdr));
@@ -239,6 +239,8 @@
 		goto error_nolock;
 	}
 	return NET_XMIT_BYPASS;
+error_free_iph:
+	kfree(iph);
 error:
 	spin_unlock_bh(&x->lock);
 error_nolock: