When incorrect core value or range provided,
as part of -l command line option, a crash occurs.
Added valid range checks to fix the crash.
Fixes: d888cb8b9613 ("eal: add core list input format")
Cc: [email protected]
Signed-off-by: Hari Kumar Vemula <[email protected]>
---
lib/librte_eal/common/eal_common_options.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/lib/librte_eal/common/eal_common_options.c
b/lib/librte_eal/common/eal_common_options.c
index e31eca5c0..ea6bb508b 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -602,6 +602,14 @@ eal_parse_corelist(const char *corelist)
max = idx;
if (min == RTE_MAX_LCORE)
min = idx;
+ if ((unsigned int)idx >= cfg->lcore_count ||
+ (unsigned int)min >= cfg->lcore_count) {
+ RTE_LOG(ERR, EAL,
+ "Invalid core number given core range
should be(0-%u)\n",
+ cfg->lcore_count);
+ return -1;
+ }
+
for (idx = min; idx <= max; idx++) {
if (cfg->lcore_role[idx] != ROLE_RTE) {
cfg->lcore_role[idx] = ROLE_RTE;
--
2.17.2