macsec: fix memory leaks when skb_to_sgvec fails
authorSabrina Dubroca <sd@queasysnail.net>
Tue, 10 Oct 2017 15:07:12 +0000 (17:07 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 11 Oct 2017 21:07:20 +0000 (14:07 -0700)
Fixes: cda7ea690350 ("macsec: check return value of skb_to_sgvec always")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/macsec.c

index 98e4deaa3a6a1c2f89d55e8f2db54b6fc93380be..5ab1b8849c30496966be05115f752bfcf3385950 100644 (file)
@@ -742,6 +742,7 @@ static struct sk_buff *macsec_encrypt(struct sk_buff *skb,
        sg_init_table(sg, ret);
        ret = skb_to_sgvec(skb, sg, 0, skb->len);
        if (unlikely(ret < 0)) {
+               aead_request_free(req);
                macsec_txsa_put(tx_sa);
                kfree_skb(skb);
                return ERR_PTR(ret);
@@ -954,6 +955,7 @@ static struct sk_buff *macsec_decrypt(struct sk_buff *skb,
        sg_init_table(sg, ret);
        ret = skb_to_sgvec(skb, sg, 0, skb->len);
        if (unlikely(ret < 0)) {
+               aead_request_free(req);
                kfree_skb(skb);
                return ERR_PTR(ret);
        }