[openib-general] [PATCH] fix list_entry usage

Sean Hefty mshefty at ichips.intel.com
Wed Oct 13 16:52:44 PDT 2004


Patch fixes casting to incorrect structures when calling list_entry().

- Sean

-- Index: access/ib_mad.c
===================================================================
--- access/ib_mad.c	(revision 987)
+++ access/ib_mad.c	(working copy)
@@ -887,10 +887,9 @@
 	 */
 	spin_lock_irqsave(&port_priv->recv_list_lock, flags);
 	if (!list_empty(&port_priv->recv_posted_mad_list[qpn])) {
-		rbuf = list_entry(&port_priv->recv_posted_mad_list[qpn],
+		rbuf = list_entry(&port_priv->recv_posted_mad_list[qpn].next,
 				 struct ib_mad_recv_buf,
 				 list);
-		rbuf = (struct ib_mad_recv_buf *)rbuf->list.next;
 		mad_priv_hdr = container_of(rbuf, struct ib_mad_private_header,
 					    recv_buf);
 		recv = container_of(mad_priv_hdr, struct ib_mad_private,
@@ -1031,7 +1030,6 @@
 				     struct ib_wc *wc)
 {
 	struct ib_mad_send_wr_private	*mad_send_wr;
-	struct list_head		*send_wr;
 	unsigned long			flags;
 
 	/* Completion corresponds to first entry on posted MAD send list */
@@ -1042,12 +1040,9 @@
 		goto error;
 	}
 
-	mad_send_wr = list_entry(&port_priv->send_posted_mad_list,
+	mad_send_wr = list_entry(&port_priv->send_posted_mad_list.next,
 				 struct ib_mad_send_wr_private,
 				 send_list);
-	send_wr = mad_send_wr->send_list.next;
-	mad_send_wr = container_of(send_wr, struct ib_mad_send_wr_private,
-				   send_list);
 	if (wc->wr_id != (unsigned long)mad_send_wr) {
 		printk(KERN_ERR PFX "Send completion WR ID 0x%Lx doesn't match "
 		       "posted send WR ID 0x%lx\n",
@@ -1383,9 +1378,8 @@
 		spin_lock_irqsave(&port_priv->recv_list_lock, flags);
 		while (!list_empty(&port_priv->recv_posted_mad_list[i])) {
 
-			rbuf = list_entry(&port_priv->recv_posted_mad_list[i],
-					   struct ib_mad_recv_buf, list);
-			rbuf = (struct ib_mad_recv_buf *)rbuf->list.next;
+			rbuf = list_entry(&port_priv->recv_posted_mad_list[i].next,
+					  struct ib_mad_recv_buf, list);
 			mad_priv_hdr = container_of(rbuf,
 						    struct ib_mad_private_header,
 						    recv_buf);




More information about the general mailing list