ipv6: Fix leak in ipv6_gso_segment().

[ Upstream commit e3e86b5119f81e5e2499bea7ea1ebe8ac6aab789 ]

If ip6_find_1stfragopt() fails and we return an error we have to free
up 'segs' because nobody else is going to.

Fixes: 2423496af35d ("ipv6: Prevent overrun when parsing v6 header options")
Change-Id: I1ab8eb06aac21a43c243d52032cdae9f8eb7a9f2
Reported-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
David S. Miller 2017-06-04 21:41:10 -04:00 committed by syphyr
parent d284770333
commit 4b21342d23
1 changed files with 3 additions and 1 deletions

View File

@ -126,8 +126,10 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb,
sizeof(*ipv6h));
if (proto == IPPROTO_UDP) {
int err = ip6_find_1stfragopt(skb, &prevhdr);
if (err < 0)
if (err < 0) {
kfree_skb_list(segs);
return ERR_PTR(err);
}
fptr = (struct frag_hdr *)(skb_network_header(skb) +
err);
fptr->frag_off = htons(offset);