From eaa3f533a5b2f469185d580a01f3e58093217242 Mon Sep 17 00:00:00 2001
From: Haruki NAOI <naoi.haruki@jp.fujitsu.com>
Date: Tue, 20 Mar 2018 13:00:21 +0900
Subject: [PATCH] Fix: segmentation fault happens when clean_eNb_dlsch()
 function is executed while pdsch procedure running.

---
 openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c
index 90450b7c1c..5e82fdcd0f 100644
--- a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c
+++ b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c
@@ -2063,6 +2063,10 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB,
   if ((dlsch0 != NULL) && (dlsch1 != NULL)){
 
     harq_pid = dlsch0->harq_ids[subframe_offset];
+    if(harq_pid >= dlsch0->Mdlharq) {
+      LOG_E(PHY,"illegal harq_pid %d\n", harq_pid);
+      return(-1);
+    }
     dlsch0_harq = dlsch0->harq_processes[harq_pid];
     mimo_mode = dlsch0_harq->mimo_mode;
     mod_order0 = dlsch0_harq->Qm;
@@ -2080,6 +2084,10 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB,
   }else if ((dlsch0 != NULL) && (dlsch1 == NULL)){
 
     harq_pid = dlsch0->harq_ids[subframe_offset];
+    if(harq_pid >= dlsch0->Mdlharq) {
+      LOG_E(PHY,"illegal harq_pid %d\n", harq_pid);
+      return(-1);
+    }
     dlsch0_harq = dlsch0->harq_processes[harq_pid];
     mimo_mode = dlsch0_harq->mimo_mode;
     mod_order0 = dlsch0_harq->Qm;
@@ -2097,6 +2105,10 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB,
   }else if ((dlsch0 == NULL) && (dlsch1 != NULL)){
 
     harq_pid = dlsch1->harq_ids[subframe_offset];
+    if(harq_pid >= dlsch1->Mdlharq) {
+      LOG_E(PHY,"illegal harq_pid %d\n", harq_pid);
+      return(-1);
+    }
     dlsch1_harq = dlsch1->harq_processes[harq_pid];
     mimo_mode = dlsch1_harq->mimo_mode;
     mod_order0 = dlsch1_harq->Qm;
-- 
GitLab