From b9ba488f00f4863fd988318bd429fa3768e59917 Mon Sep 17 00:00:00 2001 From: hselasky Date: Tue, 12 May 2015 11:52:34 +0000 Subject: [PATCH] Apply proper locking when iterating the multicast addresses and add a missing check for NULL from a non-blocking "kzalloc()" function call. MFC after: 1 week Sponsored by: Mellanox Technologies Found by: glebius @ --- sys/ofed/drivers/net/mlx4/en_netdev.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/ofed/drivers/net/mlx4/en_netdev.c b/sys/ofed/drivers/net/mlx4/en_netdev.c index 68ce12574b67..5988c0da4c59 100644 --- a/sys/ofed/drivers/net/mlx4/en_netdev.c +++ b/sys/ofed/drivers/net/mlx4/en_netdev.c @@ -650,6 +650,7 @@ static void mlx4_en_cache_mclist(struct net_device *dev) struct mlx4_en_mc_list *tmp; struct mlx4_en_priv *priv = netdev_priv(dev); + if_maddr_rlock(dev); TAILQ_FOREACH(ifma, &dev->if_multiaddrs, ifma_link) { if (ifma->ifma_addr->sa_family != AF_LINK) continue; @@ -658,10 +659,13 @@ static void mlx4_en_cache_mclist(struct net_device *dev) continue; /* Make sure the list didn't grow. */ tmp = kzalloc(sizeof(struct mlx4_en_mc_list), GFP_ATOMIC); + if (tmp == NULL) + break; memcpy(tmp->addr, LLADDR((struct sockaddr_dl *)ifma->ifma_addr), ETH_ALEN); list_add_tail(&tmp->list, &priv->mc_list); } + if_maddr_runlock(dev); } static void update_mclist_flags(struct mlx4_en_priv *priv,