[openib-general] [PATCH] [MAD] fix handing user WC structure on the stack

Sean Hefty mshefty at ichips.intel.com
Fri Mar 11 09:59:40 PST 2005


This patch replaces the ib_wc *wc field in ib_mad_recv_wc from pointing
to a structure on the stack to one allocated with the received MAD
buffer.  This allows client to access the field after their receive
completion handler has returned.

Signed-off-by: Sean Hefty <sean.hefty at intel.com>



Index: mad.c
===================================================================
--- mad.c	(revision 1964)
+++ mad.c	(working copy)
@@ -1606,7 +1606,8 @@ static void ib_mad_recv_done_handler(str
 			 DMA_FROM_DEVICE);
 
 	/* Setup MAD receive work completion from "normal" work completion */
-	recv->header.recv_wc.wc = wc;
+	recv->header.wc = *wc;
+	recv->header.recv_wc.wc = &recv->header.wc;
 	recv->header.recv_wc.mad_len = sizeof(struct ib_mad);
 	recv->header.recv_wc.recv_buf.mad = &recv->mad.mad;
 	recv->header.recv_wc.recv_buf.grh = &recv->grh;
Index: mad_priv.h
===================================================================
--- mad_priv.h	(revision 1964)
+++ mad_priv.h	(working copy)
@@ -69,6 +69,7 @@ struct ib_mad_list_head {
 struct ib_mad_private_header {
 	struct ib_mad_list_head mad_list;
 	struct ib_mad_recv_wc recv_wc;
+	struct ib_wc wc;
 	DECLARE_PCI_UNMAP_ADDR(mapping)
 } __attribute__ ((packed));
 



More information about the general mailing list