[openib-general] Re: [PATCH] SDP: fix oops with port reuse

Michael S. Tsirkin mst at mellanox.co.il
Tue Aug 16 02:19:51 PDT 2005


This is what I committed. I'm not against making sdp_inet_port_put void,
looking at libsdp this shouldnt introduce any problems, but lets make it
a separate patch.

Maybe its a good idea to init bind_next at socket creation, at port_put
we could call list_del_init, and/or use list_empty to figure out
whether the socket is on the bind list.

Quoting r. Tom Duffy <tduffy at sun.com>:
> Subject: [PATCH] SDP: fix oops with port reuse
> 
> This patch fixes an oops that I introduced in my conversion to use linux
> lists for binds (committed in revision 2874).  If two sockets tried to
> use the same port, after failing to get the port (again), it would
> attempt a put and the second attempt would oops the machine.

Signed-off-by: Tom Duffy <tduffy at sun.com>
Signed-off-by: Michael S. Tsirkin <mst at mellanox.co.il>

Index: linux-kernel/drivers/infiniband/ulp/sdp/sdp_conn.c
===================================================================
--- linux-kernel/drivers/infiniband/ulp/sdp/sdp_conn.c	(revision 3103)
+++ linux-kernel/drivers/infiniband/ulp/sdp/sdp_conn.c	(working copy)
@@ -493,16 +493,17 @@ done:
 int sdp_inet_port_put(struct sdp_sock *conn)
 {
 	unsigned long flags;
-
-	if (list_empty(&dev_root_s.bind_list))
-		return -EADDRNOTAVAIL;
+	int result = -EADDRNOTAVAIL;
 
 	spin_lock_irqsave(&dev_root_s.bind_lock, flags);
-	list_del(&conn->bind_next);
-	conn->src_port = 0;
+	if (conn->src_port) {
+		list_del(&conn->bind_next);
+		conn->src_port = 0;
+		result = 0;
+	}
 	spin_unlock_irqrestore(&dev_root_s.bind_lock, flags);
 
-	return 0;
+	return result;
 }
 
 /*

-- 
MST



More information about the general mailing list