IPoIB: In unicast_arp_send(), only free newly-created paths

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Thursday, March 26, 2009 - 4:59 pm

Gitweb:     http://git.kernel.org/linus/71d98b4628ee869d62814f6d8607d76cab4b9ec5
Commit:     71d98b4628ee869d62814f6d8607d76cab4b9ec5
Parent:     f3b8436ad9a8ad36b3c9fa1fe030c7f38e5d3d0b
Author:     Jack Morgenstein <jackm@dev.mellanox.co.il>
AuthorDate: Tue Feb 17 14:51:47 2009 -0800
Committer:  Roland Dreier <rolandd@cisco.com>
CommitDate: Tue Feb 17 14:51:47 2009 -0800

    IPoIB: In unicast_arp_send(), only free newly-created paths
    
    If path_rec_start() returns error, call path_free() only if the path
    was newly-created.  If we free an existing path whose valid flag was zero,
    (but do not detach it from the list) we cause corruption of the
    path list (of which it is a member), and get a kernel crash.
    
    The simplest solution is to not free an existing path -- just leave it
    in the list as-is (i.e., with its valid flag cleared).
    
    Thanks to Yossi Etigin of Voltaire for identifying the problem flow
    which caused the kernel crash.
    
    Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
    Signed-off-by: Moni Shua <monis@voltaire.com>
    Signed-off-by: Roland Dreier <rolandd@cisco.com>
---
 drivers/infiniband/ulp/ipoib/ipoib_main.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 0bd2a4f..353c13b 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -660,8 +660,12 @@ static void unicast_arp_send(struct sk_buff *skb, struct net_device *dev,
 
 	path = __path_find(dev, phdr->hwaddr + 4);
 	if (!path || !path->valid) {
-		if (!path)
+		int new_path = 0;
+
+		if (!path) {
 			path = path_rec_create(dev, phdr->hwaddr + 4);
+			new_path = 1;
+		}
 		if (path) {
 			/* put pseudoheader back on for next time */
 			skb_push(skb, sizeof *phdr);
@@ -669,7 +673,8 @@ static void unicast_arp_send(struct sk_buff *skb, struct net_device *dev,
 
 			if (!path->query && path_rec_start(dev, path)) {
 				spin_unlock_irqrestore(&priv->lock, flags);
-				path_free(dev, path);
+				if (new_path)
+					path_free(dev, path);
 				return;
 			} else
 				__path_add(dev, path);
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
IPoIB: In unicast_arp_send(), only free newly-created paths, Linux Kernel Mailing ..., (Thu Mar 26, 4:59 pm)