3d11c8
From 5efe6f70f310858f554287bcf7883442380a0701 Mon Sep 17 00:00:00 2001
3d11c8
From: Nathan Hjelm <hjelmn@lanl.gov>
3d11c8
Date: Tue, 28 Jun 2016 10:26:16 -0600
3d11c8
Subject: [PATCH] btl/openib: fix segmentation fault
3d11c8
3d11c8
This commit fixes a segmentation fault that occurs if a device can be
3d11c8
initialized but not used. In this case the devices_count is not equal
3d11c8
to the number of usable devices in the devices pointer array.
3d11c8
3d11c8
Thanks to @artpol84 for tracking this down.
3d11c8
3d11c8
Fixes open-mpi/ompi#1823
3d11c8
3d11c8
Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
3d11c8
(cherry picked from commit 8128c8eb29d6adde288fca5db3f71fb98e1727f6)
3d11c8
---
3d11c8
 ompi/mca/btl/openib/btl_openib_component.c | 4 +++-
3d11c8
 1 file changed, 3 insertions(+), 1 deletion(-)
3d11c8
3d11c8
diff --git a/ompi/mca/btl/openib/btl_openib_component.c b/ompi/mca/btl/openib/btl_openib_component.c
3d11c8
index 40831f2373..d1376e0a58 100644
3d11c8
--- a/ompi/mca/btl/openib/btl_openib_component.c
3d11c8
+++ b/ompi/mca/btl/openib/btl_openib_component.c
3d11c8
@@ -3630,7 +3630,9 @@ static int btl_openib_component_progress(void)
3d11c8
     for(i = 0; i < mca_btl_openib_component.devices_count; i++) {
3d11c8
         mca_btl_openib_device_t *device =
3d11c8
             (mca_btl_openib_device_t *) opal_pointer_array_get_item(&mca_btl_openib_component.devices, i);
3d11c8
-        count += progress_one_device(device);
3d11c8
+        if (NULL != device) {
3d11c8
+            count += progress_one_device(device);
3d11c8
+        }
3d11c8
     }
3d11c8
 
3d11c8
 #if OPAL_CUDA_SUPPORT /* CUDA_ASYNC_SEND */
3d11c8
-- 
3d11c8
2.13.5
3d11c8