[openib-general] [PATCH] Fix MMU if find_mad_agent() finds no agent.

Krishna Kumar krkumar at us.ibm.com
Mon Nov 1 18:02:54 PST 2004


This fixes the above case and I also took the liberty of changing
"goto ret" to "goto out", which just looks more aesthetic.

I am not including inline, since my patches seem to get inlined
automatically and without getting mangled. Hope this continues :-)

Thanks,

- KK
-------------- next part --------------
diff -ruNp 1/mad.c 2/mad.c
--- 1/mad.c	2004-11-01 17:57:02.000000000 -0800
+++ 2/mad.c	2004-11-01 17:59:03.000000000 -0800
@@ -660,7 +660,7 @@ static void remove_mad_reg_req(struct ib
 
 	/* Was MAD registration request supplied with original registration ? */
 	if (!agent_priv->reg_req) {
-		goto ret;
+		goto out;
 	}
 
 	port_priv = agent_priv->port_priv;
@@ -668,7 +668,7 @@ static void remove_mad_reg_req(struct ib
 	if (!class) {
 		printk(KERN_ERR PFX "No class table yet MAD registration "
 		       "request supplied\n");
-		goto ret;
+		goto out;
 	}
 
 	mgmt_class = convert_mgmt_class(agent_priv->reg_req->mgmt_class);
@@ -691,7 +691,7 @@ static void remove_mad_reg_req(struct ib
 		}
 	}
 
-ret:
+out:
 	return;
 }
 
@@ -753,7 +753,7 @@ find_mad_agent(struct ib_mad_port_privat
 		if (!mad_agent) {
 			printk(KERN_ERR PFX "No client 0x%x for received MAD "
 			       "on port %d\n", hi_tid, port_priv->port_num);
-			goto ret;
+			goto out;
 		}
 	} else {
 		/* Routing is based on version, class, and method */
@@ -761,14 +761,14 @@ find_mad_agent(struct ib_mad_port_privat
 			printk(KERN_ERR PFX "MAD received with unsupported "
 			       "class version %d on port %d\n",
 			       mad->mad_hdr.class_version, port_priv->port_num);
-			goto ret;
+			goto out;
 		}
 		version = port_priv->version[mad->mad_hdr.class_version];
 		if (!version) {
 			printk(KERN_ERR PFX "MAD received on port %d for class "
 			       "version %d with no client\n",
 			       port_priv->port_num, mad->mad_hdr.class_version);
-			goto ret;
+			goto out;
 		}
 		class = version->method_table[convert_mgmt_class(
 						mad->mad_hdr.mgmt_class)];
@@ -776,18 +776,17 @@ find_mad_agent(struct ib_mad_port_privat
 			printk(KERN_ERR PFX "MAD received on port %d for class "
 			       "%d with no client\n",
 			       port_priv->port_num, mad->mad_hdr.mgmt_class);
-			goto ret;
+			goto out;
 		}
 		mad_agent = class->agent[mad->mad_hdr.method &
 					 ~IB_MGMT_METHOD_RESP];		
 	}
 
-ret:
-	if (!mad_agent->agent.recv_handler) {
+out:
+	if (mad_agent && !mad_agent->agent.recv_handler) {
 		printk(KERN_ERR PFX "No receive handler for client "
 		       "%p on port %d\n",
-		       &mad_agent->agent,
-		       port_priv->port_num);
+		       &mad_agent->agent, port_priv->port_num);
 		mad_agent = NULL;
 	}
 
@@ -802,7 +801,7 @@ static int validate_mad(struct ib_mad *m
 	if (mad->mad_hdr.base_version != IB_MGMT_BASE_VERSION) {
 		printk(KERN_ERR PFX "MAD received with unsupported base "
 		       "version %d\n", mad->mad_hdr.base_version);
-		goto ret;
+		goto out;
 	}
 
 	/* Filter SMI packets sent to other than QP0 */
@@ -816,7 +815,7 @@ static int validate_mad(struct ib_mad *m
 			valid = 1;	
 	}
 
-ret:
+out:
 	return valid;
 }
 
@@ -978,7 +977,7 @@ static void ib_mad_recv_done_handler(str
 
 	/* Validate MAD */
 	if (!validate_mad(recv->header.recv_buf.mad, qp_num))
-		goto ret;
+		goto out;
 
 	/* Snoop MAD ? */
 	if (port_priv->device->snoop_mad)
@@ -986,7 +985,7 @@ static void ib_mad_recv_done_handler(str
 						 (u8)port_priv->port_num,
 						 wc->slid,
 						 recv->header.recv_buf.mad))
-			goto ret;
+			goto out;
 
 	spin_lock_irqsave(&port_priv->reg_lock, flags);
 	/* Determine corresponding MAD agent for incoming receive MAD */
@@ -1003,7 +1002,7 @@ static void ib_mad_recv_done_handler(str
 		ib_mad_complete_recv(mad_agent, recv, solicited);
 	}
 
-ret:
+out:
 	if (!mad_agent) {
 		/* Should this case be optimized ? */
 		kmem_cache_free(ib_mad_cache, recv);
@@ -1255,7 +1254,7 @@ void ib_cancel_mad(struct ib_mad_agent *
 	mad_send_wr = find_send_by_wr_id(mad_agent_priv, wr_id);
 	if (!mad_send_wr) {
 		spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
-		goto ret;
+		goto out;
 	}
 
 	if (mad_send_wr->status == IB_WC_SUCCESS)
@@ -1264,7 +1263,7 @@ void ib_cancel_mad(struct ib_mad_agent *
 	if (mad_send_wr->refcount != 0) {
 		mad_send_wr->status = IB_WC_WR_FLUSH_ERR;
 		spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
-		goto ret;
+		goto out;
 	}
 
 	list_del(&mad_send_wr->agent_list);
@@ -1281,7 +1280,7 @@ void ib_cancel_mad(struct ib_mad_agent *
 	if (atomic_dec_and_test(&mad_agent_priv->refcount))
 		wake_up(&mad_agent_priv->wait);
 
-ret:
+out:
 	return;
 }
 EXPORT_SYMBOL(ib_cancel_mad);


More information about the general mailing list