esp6: fix memleak on error path in esp6_input
authorZhen Lei <thunder.leizhen@huawei.com>
Wed, 27 Jun 2018 03:49:28 +0000 (11:49 +0800)
committerSteffen Klassert <steffen.klassert@secunet.com>
Wed, 27 Jun 2018 15:32:11 +0000 (17:32 +0200)
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 <thunder.leizhen@huawei.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
net/ipv6/esp6.c

index 97513f3..88a7579 100644 (file)
@@ -669,8 +669,10 @@ skip_cow:
 
        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;
+       }
 
        skb->ip_summed = CHECKSUM_NONE;