[ipxe-devel] [PATCH] [ipoib, infiniband] Fix a race when chain-loading undionly.kpxe in IPoIB

Wissam Shoukair wissams at mellanox.com
Wed Aug 12 09:32:28 UTC 2015


Signed-off-by: Wissam Shoukair <wissams at mellanox.com>
---
 src/drivers/net/ipoib.c | 4 +++-
 src/net/infiniband.c    | 3 +++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/drivers/net/ipoib.c b/src/drivers/net/ipoib.c index 7ecb2c5..55b5e36 100644
--- a/src/drivers/net/ipoib.c
+++ b/src/drivers/net/ipoib.c
@@ -806,7 +806,7 @@ static void ipoib_link_state_changed ( struct ib_device *ibdev ) {
 	netdev_link_err ( netdev, ( rc ? rc : -EINPROGRESS_JOINING ) );
 
 	/* Join new broadcast group */
-	if ( ib_is_open ( ibdev ) && ib_link_ok ( ibdev ) &&
+	if ( ib_is_open ( ibdev ) && ib_link_ok ( ibdev ) && ( ipoib->qp ) &&
 	     ( ( rc = ipoib_join_broadcast_group ( ipoib ) ) != 0 ) ) {
 		DBGC ( ipoib, "IPoIB %p could not rejoin broadcast group: "
 		       "%s\n", ipoib, strerror ( rc ) ); @@ -894,7 +894,9 @@ static void ipoib_close ( struct net_device *netdev ) {
 
 	/* Tear down the queues */
 	ib_destroy_qp ( ibdev, ipoib->qp );
+	ipoib->qp = NULL;
 	ib_destroy_cq ( ibdev, ipoib->cq );
+	ipoib->cq = NULL;
 
 	/* Close IB device */
 	ib_close ( ibdev );
diff --git a/src/net/infiniband.c b/src/net/infiniband.c index 8ba031f..aea13db 100644
--- a/src/net/infiniband.c
+++ b/src/net/infiniband.c
@@ -718,6 +718,9 @@ int ib_mcast_attach ( struct ib_device *ibdev, struct ib_queue_pair *qp,
 	struct ib_multicast_gid *mgid;
 	int rc;
 
+	if ( qp == NULL )
+		return -EFAULT;
+
 	/* Add to software multicast GID list */
 	mgid = zalloc ( sizeof ( *mgid ) );
 	if ( ! mgid ) {
--
1.9.4




More information about the ipxe-devel mailing list