From e93df742ed73889eded5e797668320e73cfcabb866e4c30bb5bab57f222edfcc Mon Sep 17 00:00:00 2001
From: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
Date: Thu, 2 May 2019 08:27:53 +0000
Subject: [PATCH] Accepting request 700039 from
 home:NMoreyChaisemartin:branches:science:HPC

- Add mvapich2-fix-double-free.patch to fix a segfault
  when running on a machine with no RDMA hardware (bsc#1133797)

OBS-URL: https://build.opensuse.org/request/show/700039
OBS-URL: https://build.opensuse.org/package/show/science:HPC/mvapich2?expand=0&rev=56
---
 mvapich2-fix-double-free.patch | 24 ++++++++++++++++++++++++
 mvapich2.changes               |  6 ++++++
 mvapich2.spec                  |  2 ++
 3 files changed, 32 insertions(+)
 create mode 100644 mvapich2-fix-double-free.patch

diff --git a/mvapich2-fix-double-free.patch b/mvapich2-fix-double-free.patch
new file mode 100644
index 0000000..2067e18
--- /dev/null
+++ b/mvapich2-fix-double-free.patch
@@ -0,0 +1,24 @@
+commit 02b05116e1586422a933c4a8f6d4e4d29d4e9531
+Author: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
+Date:   Thu May 2 09:56:40 2019 +0200
+
+    mvapich2 fix double free
+    
+    Fix double free that causes a SEGV when mvapich2 fails to open
+     a rdma device
+    
+    Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
+
+diff --git src/mpid/ch3/channels/mrail/src/gen2/rdma_iba_priv.c src/mpid/ch3/channels/mrail/src/gen2/rdma_iba_priv.c
+index 4366eb521fce..95d09efa75e3 100644
+--- src/mpid/ch3/channels/mrail/src/gen2/rdma_iba_priv.c
++++ src/mpid/ch3/channels/mrail/src/gen2/rdma_iba_priv.c
+@@ -707,8 +707,6 @@ int rdma_open_hca(struct mv2_MPIDI_CH3I_RDMA_Process_t *proc)
+     return mpi_errno;
+ 
+   fn_fail:
+-    /* Clean up before exit */
+-    ibv_free_device_list(dev_list);
+     goto fn_exit;
+ }
+ 
diff --git a/mvapich2.changes b/mvapich2.changes
index 7f113c6..a677d68 100644
--- a/mvapich2.changes
+++ b/mvapich2.changes
@@ -1,3 +1,9 @@
+-------------------------------------------------------------------
+Thu May  2 08:00:51 UTC 2019 - Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
+
+- Add mvapich2-fix-double-free.patch to fix a segfault
+  when running on a machine with no RDMA hardware (bsc#1133797)
+
 -------------------------------------------------------------------
 Wed Mar 20 19:01:00 UTC 2019 - Ana Guerrero Lopez <aguerrero@suse.com>
 
diff --git a/mvapich2.spec b/mvapich2.spec
index 1fcadf7..510b76c 100644
--- a/mvapich2.spec
+++ b/mvapich2.spec
@@ -167,6 +167,7 @@ Patch2:         mvapich2-arm-support.patch
 # PATCH-FIX-UPSTREAM 0001-Drop-GCC-check.patch (bnc#1129421)
 # It's been merged upstream, should be removed with the next release
 Patch3:         0001-Drop-GCC-check.patch
+Patch4:         mvapich2-fix-double-free.patch
 Url:            http://mvapich.cse.ohio-state.edu/overview/mvapich2/
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 
@@ -297,6 +298,7 @@ is based on MPICH2 and MVICH. This package contains the static libraries
 %patch0
 %patch2
 %patch3
+%patch4
 cp /usr/share/automake*/config.* .
 
 %build