[openib-general] [PATCH] fix memory leak and return value associated with agent_mad_send(response)

Shirley Ma mashirle at us.ibm.com
Wed Nov 3 10:56:29 PST 2004


Here is the patch. Please review it.

diff -urN access/agent.c access.patch6/agent.c
--- access/agent.c	2004-11-03 10:34:17.941019320 -0800
+++ access.patch6/agent.c	2004-11-03 10:54:16.001886384 -0800
@@ -477,8 +477,10 @@
 				return 0;
 			}
 			if (agent_mad_send(mad_agent, smp_response,
-					   NULL, mad_recv_wc))
+					   NULL, mad_recv_wc)) {
 				kfree(smp_response);
+				return 0;
+			}
 		} else
 			kfree(smp_response);
 		return 1;
@@ -504,7 +506,10 @@
 	ret = mad_process_local(mad_agent, mad, response, slid);
 	if (ret & IB_MAD_RESULT_SUCCESS) {
 		grh = (void *)mad - sizeof(struct ib_grh);
-		agent_mad_send(mad_agent, response, grh, mad_recv_wc);
+		if (agent_mad_send(mad_agent, response, grh, mad_recv_wc)) {
+			kfree(response);
+			return 0;
+		}
 	} else
 		kfree(response);
 	return 1;
@@ -543,12 +548,12 @@
 	} else {
 		/* PerfMgmt class */
 		if (mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT) {
-			agent_mad_response(mad_agent, mad, mad_recv_wc,
-					   mad_recv_wc->wc->slid);
+			return (agent_mad_response(mad_agent, mad, mad_recv_wc,
+						   mad_recv_wc->wc->slid));
 		} else {
 			printk(KERN_ERR "agent_recv_mad: Unexpected mgmt class 0x%x received\n", 
mad->mad_hdr.mgmt_class);
+			return 0;
 		}
-		return 0;
 	}
 
 	/* Complete receive up stack */



-- 
Thanks
Shirley Ma
IBM Linux Technology Center



More information about the general mailing list