aboutsummaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorWissam Shoukair <wissams@mellanox.com>2015-08-12 12:28:58 +0300
committerMichael Brown <mcb30@ipxe.org>2015-08-17 14:42:36 +0100
commiteb8df9a0466078f083822e5ef2fb16713c94d25c (patch)
treef42ae5a6ad32a2e1a04139894cece0c0dc3c3a67 /src/net
parentfd18417cf1208399bfa0153c6ec26c268d2f948e (diff)
downloadipxe-eb8df9a0466078f083822e5ef2fb16713c94d25c.zip
ipxe-eb8df9a0466078f083822e5ef2fb16713c94d25c.tar.gz
ipxe-eb8df9a0466078f083822e5ef2fb16713c94d25c.tar.bz2
[ipoib] Fix a race when chain-loading undionly.kpxe in IPoIB
The Infiniband link status change callback ipoib_link_state_changed() may be called while the IPoIB device is closed, in which case there will not be an IPoIB queue pair to be joined to the IPv4 broadcast group. This leads to NULL pointer dereferences in ib_mcast_attach() and ib_mcast_detach(). Fix by not attempting to join (or leave) the broadcast group unless we actually have an IPoIB queue pair. Signed-off-by: Wissam Shoukair <wissams@mellanox.com> Modified-by: Michael Brown <mcb30@ipxe.org> Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/net')
-rw-r--r--src/net/infiniband.c6
-rw-r--r--src/net/infiniband/ib_mcast.c6
2 files changed, 12 insertions, 0 deletions
diff --git a/src/net/infiniband.c b/src/net/infiniband.c
index 8ba031f..2e3d76d 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;
+ /* Sanity check */
+ assert ( qp != NULL );
+
/* Add to software multicast GID list */
mgid = zalloc ( sizeof ( *mgid ) );
if ( ! mgid ) {
@@ -751,6 +754,9 @@ void ib_mcast_detach ( struct ib_device *ibdev, struct ib_queue_pair *qp,
union ib_gid *gid ) {
struct ib_multicast_gid *mgid;
+ /* Sanity check */
+ assert ( qp != NULL );
+
/* Remove from hardware multicast GID list */
ibdev->op->mcast_detach ( ibdev, qp, gid );
diff --git a/src/net/infiniband/ib_mcast.c b/src/net/infiniband/ib_mcast.c
index 0236926..fc4ff7f 100644
--- a/src/net/infiniband/ib_mcast.c
+++ b/src/net/infiniband/ib_mcast.c
@@ -150,6 +150,9 @@ int ib_mcast_join ( struct ib_device *ibdev, struct ib_queue_pair *qp,
DBGC ( ibdev, "IBDEV %p QPN %lx joining " IB_GID_FMT "\n",
ibdev, qp->qpn, IB_GID_ARGS ( gid ) );
+ /* Sanity check */
+ assert ( qp != NULL );
+
/* Initialise structure */
membership->qp = qp;
memcpy ( &membership->gid, gid, sizeof ( membership->gid ) );
@@ -199,6 +202,9 @@ void ib_mcast_leave ( struct ib_device *ibdev, struct ib_queue_pair *qp,
DBGC ( ibdev, "IBDEV %p QPN %lx leaving " IB_GID_FMT "\n",
ibdev, qp->qpn, IB_GID_ARGS ( gid ) );
+ /* Sanity check */
+ assert ( qp != NULL );
+
/* Detach from multicast GID */
ib_mcast_detach ( ibdev, qp, &membership->gid );