macsec: add missing NULL check after kmalloc
authorSabrina Dubroca <sd@queasysnail.net>
Fri, 22 Apr 2016 09:28:01 +0000 (11:28 +0200)
committerDavid S. Miller <davem@davemloft.net>
Sun, 24 Apr 2016 18:31:58 +0000 (14:31 -0400)
Fixes: c09440f7dcb3 ("macsec: introduce IEEE 802.1AE driver")
Reported-by: Dan Carpenter <dan.carpenter@oracle.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>
drivers/net/macsec.c

index 84d3e5c..f691030 100644 (file)
@@ -1622,8 +1622,8 @@ static int macsec_add_rxsa(struct sk_buff *skb, struct genl_info *info)
        }
 
        rx_sa = kmalloc(sizeof(*rx_sa), GFP_KERNEL);
-       if (init_rx_sa(rx_sa, nla_data(tb_sa[MACSEC_SA_ATTR_KEY]), secy->key_len,
-                      secy->icv_len)) {
+       if (!rx_sa || init_rx_sa(rx_sa, nla_data(tb_sa[MACSEC_SA_ATTR_KEY]),
+                                secy->key_len, secy->icv_len)) {
                rtnl_unlock();
                return -ENOMEM;
        }