[openib-general] [PATCH] ib_mad: Fix ib_free_recv_mad
Hal Rosenstock
halr at voltaire.com
Tue Sep 28 16:06:22 PDT 2004
ib_mad: Fix ib_free_recv_mad
Index: ib_mad.c
===================================================================
--- ib_mad.c (revision 901)
+++ ib_mad.c (working copy)
@@ -394,8 +394,12 @@
void ib_free_recv_mad(struct ib_mad_recv_wc *mad_recv_wc)
{
struct ib_mad_recv_buf *entry;
- struct ib_mad_private *buffer = (struct ib_mad_private
*)mad_recv_wc;
+ struct ib_mad_private_header *mad_priv_hdr;
+ struct ib_mad_private *buffer;
+ mad_priv_hdr = container_of(mad_recv_wc, struct
ib_mad_private_header, r
ecv_wc);
+ buffer = container_of(mad_priv_hdr, struct ib_mad_private,
header);
+
/*
* Walk receive buffer list associated with this WC
* No need to remove them from list of receive buffers
@@ -403,7 +407,8 @@
list_for_each_entry(entry, &mad_recv_wc->recv_buf->list, list) {
/* Free previous receive buffer */
kmem_cache_free(ib_mad_cache, buffer);
- buffer = (void *)entry - sizeof(struct
ib_mad_private_header);
+ mad_priv_hdr = container_of(entry, struct
ib_mad_private_header,
recv_buf);
+ buffer = container_of(mad_priv_hdr, struct
ib_mad_private, heade
r);
}
/* Free last buffer */
kmem_cache_free(ib_mad_cache, buffer);
@@ -768,7 +773,7 @@
recv->header.recv_wc.recv_buf = &recv->header.recv_buf;
/* Setup MAD receive buffer */
- recv->header.recv_buf.list.next = NULL; /* Until RMPP
implemented !!! */
+ INIT_LIST_HEAD(&recv->header.recv_buf.list); /* More for RMPP!!!
*/
recv->header.recv_buf.mad = (struct ib_mad *)&recv->mad;
if (wc->wc_flags & IB_WC_GRH) {
recv->header.recv_buf.grh = &recv->grh;
More information about the general
mailing list