macsec: Fix memory leaks in macsec_decrypt()
Subsystems (3)
PATCH 1/1 macsec: Fix memory leaks in macsec_decrypt()
In the implementation of macsec_decrypt(), there are two memory leaks when crypto_aead_decrypt() fails. Release allocated req and skb before return.
Fixes c3b7d0bd7ac2 ("macsec: fix rx_sa refcounting with decrypt callback")
Signed-off-by Navid Emamdoost <[email protected]>
--- drivers/net/macsec.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/macsec.c +2 -0
@@ -986,6 +986,8 @@ static struct sk_buff *macsec_decrypt(struct sk_buff *skb,dev_hold (dev); ret =crypto_aead_decrypt (req);if (ret == -EINPROGRESS ) { +aead_request_free (req); +kfree_skb (skb);return ERR_PTR (ret); }else if (ret !=0 ) {/* decryption/authentication failed
Signature · 1 line
2.17.1
Quoted 15 lines · Navid Emamdoost
In the implementation of
macsec_decrypt(), there are two memory leaks whencrypto_aead_decrypt()fails. Release allocated req and skb before return.Fixes c3b7d0bd7ac2 ("macsec: fix rx_sa refcounting with decrypt callback")Signed-off-by Navid Emamdoost <[email protected]>--- drivers/net/macsec.c | 2 ++ 1 file changed, 2 insertions(+)drivers/net/macsec.c +0
-0
drivers/net/macsec.c static struct sk_buff *macsec_decrypt(struct sk_buff *skb, · line 990
Quoted 5 lines
drivers/net/macsec.c +2
-0@@ -986,6 +986,8 @@ static struct sk_buff *macsec_decrypt(struct sk_buff *skb,dev_hold (dev); ret =crypto_aead_decrypt (req);if (ret == -EINPROGRESS ) { +aead_request_free (req); +kfree_skb (skb);
-EINPROGRESS means decryption is handled asynchronously, no?
drivers/net/macsec.c static struct sk_buff *macsec_decrypt(struct sk_buff *skb, · line 993
Quoted 3 lines
drivers/net/macsec.c +0
-0return ERR_PTR (ret); }else if (ret !=0 ) {/* decryption/authentication failed
This is the error handling/failure path.