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