From: Zhen Lei Date: Wed, 27 Jun 2018 03:49:28 +0000 (+0800) Subject: esp6: fix memleak on error path in esp6_input X-Git-Tag: v4.9.227~40 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7aebadb465fe3d7798a42d3de6907da7ac78419d;p=platform%2Fkernel%2Flinux-amlogic.git esp6: fix memleak on error path in esp6_input commit 7284fdf39a912322ce97de2d30def3c6068a418c upstream. This ought to be an omission in e6194923237 ("esp: Fix memleaks on error paths."). The memleak on error path in esp6_input is similar to esp_input of esp4. Fixes: e6194923237 ("esp: Fix memleaks on error paths.") Fixes: 3f29770723f ("ipsec: check return value of skb_to_sgvec always") Signed-off-by: Zhen Lei Signed-off-by: Steffen Klassert Cc: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c index 6a924be..da158a3 100644 --- a/net/ipv6/esp6.c +++ b/net/ipv6/esp6.c @@ -426,8 +426,10 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb) sg_init_table(sg, nfrags); ret = skb_to_sgvec(skb, sg, 0, skb->len); - if (unlikely(ret < 0)) + if (unlikely(ret < 0)) { + kfree(tmp); goto out; + } aead_request_set_crypt(req, sg, sg, elen + ivlen, iv); aead_request_set_ad(req, assoclen);