diff mbox series

[v2,2/2] eal: fix service core index validity

Message ID 1619663653-22771-3-git-send-email-humin29@huawei.com (mailing list archive)
State Superseded
Delegated to: Thomas Monjalon
Headers show
Series fix bugs for librte eal | expand

Checks

Context Check Description
ci/intel-Testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/github-robot success github build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/checkpatch success coding style OK

Commit Message

Min Hu (Connor) April 29, 2021, 2:34 a.m. UTC
This patch adds checking for service core index validity when parsing
service corelist.

Fixes: 7dbd7a6413ef ("service: add -S corelist option")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 lib/eal/common/eal_common_options.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Thomas Monjalon May 4, 2021, 4:54 p.m. UTC | #1
+Cc Harry

29/04/2021 04:34, Min Hu (Connor):
> This patch adds checking for service core index validity when parsing
> service corelist.
> 
> Fixes: 7dbd7a6413ef ("service: add -S corelist option")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
> ---
>  lib/eal/common/eal_common_options.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c
> index 66f9114..97ab6e0 100644
> --- a/lib/eal/common/eal_common_options.c
> +++ b/lib/eal/common/eal_common_options.c
> @@ -758,10 +758,10 @@ static int
>  eal_parse_service_corelist(const char *corelist)
>  {
>  	struct rte_config *cfg = rte_eal_get_configuration();
> -	int i, idx = 0;
> +	int i;
>  	unsigned count = 0;
>  	char *end = NULL;
> -	int min, max;
> +	uint32_t min, max, idx;
>  	uint32_t taken_lcore_count = 0;
>  
>  	if (corelist == NULL)
> @@ -785,6 +785,8 @@ eal_parse_service_corelist(const char *corelist)
>  		idx = strtoul(corelist, &end, 10);
>  		if (errno || end == NULL)
>  			return -1;
> +		if (idx >= RTE_MAX_LCORE)
> +			return -1;
>  		while (isblank(*end))
>  			end++;
>  		if (*end == '-') {
>
diff mbox series

Patch

diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c
index 66f9114..97ab6e0 100644
--- a/lib/eal/common/eal_common_options.c
+++ b/lib/eal/common/eal_common_options.c
@@ -758,10 +758,10 @@  static int
 eal_parse_service_corelist(const char *corelist)
 {
 	struct rte_config *cfg = rte_eal_get_configuration();
-	int i, idx = 0;
+	int i;
 	unsigned count = 0;
 	char *end = NULL;
-	int min, max;
+	uint32_t min, max, idx;
 	uint32_t taken_lcore_count = 0;
 
 	if (corelist == NULL)
@@ -785,6 +785,8 @@  eal_parse_service_corelist(const char *corelist)
 		idx = strtoul(corelist, &end, 10);
 		if (errno || end == NULL)
 			return -1;
+		if (idx >= RTE_MAX_LCORE)
+			return -1;
 		while (isblank(*end))
 			end++;
 		if (*end == '-') {