From 73b79d29bc926a87e317c3881c197fc2db64e9d0 Mon Sep 17 00:00:00 2001 From: Xavier Simonart Date: Wed, 4 Sep 2019 14:07:53 +0200 Subject: Fix parsing parameter errors in start and stop commands Some wrong parameters in start (such as "start all 4" while there are only less than 4 tasks available on some cores) and stop command could have potentially caused a crash in some cases. Change-Id: I6dc201575b574c53ded242ea795c35de82fb787e Signed-off-by: Xavier Simonart --- VNFs/DPPD-PROX/lconf.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'VNFs/DPPD-PROX/lconf.c') diff --git a/VNFs/DPPD-PROX/lconf.c b/VNFs/DPPD-PROX/lconf.c index 935bac5d..23ae58eb 100644 --- a/VNFs/DPPD-PROX/lconf.c +++ b/VNFs/DPPD-PROX/lconf.c @@ -127,6 +127,10 @@ static void msg_stop(struct lcore_cfg *lconf) idx++; } } + // Check that task id is valid and running + if (idx == -1) + return; + lconf->task_is_running[lconf->msg.task_id] = 0; t = lconf->tasks_all[lconf->msg.task_id]; @@ -155,8 +159,14 @@ static void msg_start(struct lcore_cfg *lconf) t->aux->start(t); } lconf->n_tasks_run = lconf->n_tasks_all; + return; } - else if (lconf->n_tasks_run == 0) { + + // Check that task id is valid + if (lconf->msg.task_id >= lconf->n_tasks_all) + return; + + if (lconf->n_tasks_run == 0) { t = lconf->tasks_run[0] = lconf->tasks_all[lconf->msg.task_id]; lconf->n_tasks_run = 1; lconf->task_is_running[lconf->msg.task_id] = 1; @@ -167,9 +177,13 @@ static void msg_start(struct lcore_cfg *lconf) t->aux->start(t); } else { + if (lconf->task_is_running[lconf->msg.task_id]) + return; for (int i = lconf->n_tasks_run - 1; i >= 0; --i) { idx = lconf_get_task_id(lconf, lconf->tasks_run[i]); if (idx == lconf->msg.task_id) { + // We should not come here as checking earlier if task id is running... + plog_warn("Unexpectedly get request to start task %d already running\n", idx); break; } else if (idx > lconf->msg.task_id) { -- cgit 1.2.3-korg