diff --git a/openair2/F1AP/f1ap_common.c b/openair2/F1AP/f1ap_common.c
index ea8b2c6739b964e51767a8e0f4f1f35c0aab86d5..267626dd5ceecddea419461d7b2f7895d3430915 100644
--- a/openair2/F1AP/f1ap_common.c
+++ b/openair2/F1AP/f1ap_common.c
@@ -187,7 +187,7 @@ int f1ap_cu_add_du_ue_id(f1ap_cudu_inst_t *f1_inst,
                          module_id_t       cu_ue_f1ap_id,
                          module_id_t       du_ue_f1ap_id) {
   module_id_t f1ap_uid = f1ap_get_cu_uid(f1_inst,cu_ue_f1ap_id);
-  if (f1ap_uid < 0) return -1;
+  if (f1ap_uid < 0 || f1ap_uid >= MAX_MOBILES_PER_ENB) return -1;
   f1_inst->f1ap_ue[f1ap_uid].du_ue_f1ap_id = du_ue_f1ap_id;
   LOG_I(F1AP, "Adding du_ue_f1ap_id %d for UE with RNTI %x\n", du_ue_f1ap_id, f1_inst->f1ap_ue[f1ap_uid].rnti);
   return 0;