[openib-general] [PATCH] ipoib: send only multicast objects memory leak

Michael S. Tsirkin mst at mellanox.co.il
Wed Jan 4 03:29:37 PST 2006


Send only multicast groups currently stay on multicast_list forever.
Clean them at ipoib_mcast_dev_down.

Signed-off-by: Eli Cohen <eli at mellanox.co.il>
Signed-off-by: Michael S. Tsirkin <mst at mellanox.co.il>

Index: latest/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
===================================================================
--- latest.orig/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
+++ latest/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
@@ -808,18 +808,29 @@ void ipoib_mcast_dev_down(struct net_dev
 {
 	struct ipoib_dev_priv *priv = netdev_priv(dev);
 	unsigned long flags;
+	struct ipoib_mcast *mcast, *tmcast;
+	LIST_HEAD(remove_list);
+
+	spin_lock_irqsave(&priv->lock, flags);
+	list_for_each_entry_safe(mcast, tmcast, &priv->multicast_list, list) {
+		list_del_init(&mcast->list);
+		rb_erase(&mcast->rb_node, &priv->multicast_tree);
+		list_add(&mcast->list, &remove_list);
+	}
 
 	/* Delete broadcast since it will be recreated */
 	if (priv->broadcast) {
 		ipoib_dbg_mcast(priv, "deleting broadcast group\n");
-
-		spin_lock_irqsave(&priv->lock, flags);
 		rb_erase(&priv->broadcast->rb_node, &priv->multicast_tree);
-		spin_unlock_irqrestore(&priv->lock, flags);
-		ipoib_mcast_leave(dev, priv->broadcast);
-		ipoib_mcast_free(priv->broadcast);
+		list_add_tail(&priv->broadcast->list, &remove_list);
 		priv->broadcast = NULL;
 	}
+	spin_unlock_irqrestore(&priv->lock, flags);
+
+	list_for_each_entry_safe(mcast, tmcast, &remove_list, list) {
+		ipoib_mcast_leave(dev, mcast);
+		ipoib_mcast_free(mcast);
+	}
 }
 
 void ipoib_mcast_restart_task(void *dev_ptr)

-- 
MST



More information about the general mailing list