diff options
author | Sabrina Dubroca <sd@queasysnail.net> | 2016-04-22 05:28:07 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-04-24 14:31:58 -0400 |
commit | 38787fc209580f9b5918e93e71da7c960dbb5d8d (patch) | |
tree | 8ecadb5f7f15a29c8cbbc4c74197c922a3bbf379 /drivers/net/macsec.c | |
parent | 960d5848dbf1245cc3a310109897937207411c0c (diff) |
macsec: fix SA leak if initialization fails
Fixes: c09440f7dcb3 ("macsec: introduce IEEE 802.1AE driver")
Reported-by: Lance Richardson <lrichard@redhat.com>
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/macsec.c')
-rw-r--r-- | drivers/net/macsec.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c index 826c6c9ce7fd..b37d348b8ea0 100644 --- a/drivers/net/macsec.c +++ b/drivers/net/macsec.c | |||
@@ -1627,6 +1627,7 @@ static int macsec_add_rxsa(struct sk_buff *skb, struct genl_info *info) | |||
1627 | rx_sa = kmalloc(sizeof(*rx_sa), GFP_KERNEL); | 1627 | rx_sa = kmalloc(sizeof(*rx_sa), GFP_KERNEL); |
1628 | if (!rx_sa || init_rx_sa(rx_sa, nla_data(tb_sa[MACSEC_SA_ATTR_KEY]), | 1628 | if (!rx_sa || init_rx_sa(rx_sa, nla_data(tb_sa[MACSEC_SA_ATTR_KEY]), |
1629 | secy->key_len, secy->icv_len)) { | 1629 | secy->key_len, secy->icv_len)) { |
1630 | kfree(rx_sa); | ||
1630 | rtnl_unlock(); | 1631 | rtnl_unlock(); |
1631 | return -ENOMEM; | 1632 | return -ENOMEM; |
1632 | } | 1633 | } |
@@ -1771,6 +1772,7 @@ static int macsec_add_txsa(struct sk_buff *skb, struct genl_info *info) | |||
1771 | tx_sa = kmalloc(sizeof(*tx_sa), GFP_KERNEL); | 1772 | tx_sa = kmalloc(sizeof(*tx_sa), GFP_KERNEL); |
1772 | if (!tx_sa || init_tx_sa(tx_sa, nla_data(tb_sa[MACSEC_SA_ATTR_KEY]), | 1773 | if (!tx_sa || init_tx_sa(tx_sa, nla_data(tb_sa[MACSEC_SA_ATTR_KEY]), |
1773 | secy->key_len, secy->icv_len)) { | 1774 | secy->key_len, secy->icv_len)) { |
1775 | kfree(tx_sa); | ||
1774 | rtnl_unlock(); | 1776 | rtnl_unlock(); |
1775 | return -ENOMEM; | 1777 | return -ENOMEM; |
1776 | } | 1778 | } |