diff mbox

test/performance:Avoid possible out-of-bounds memory access

Message ID 1459761101-21867-1-git-send-email-balakrishna.garapati@linaro.org
State Superseded
Headers show

Commit Message

Balakrishna Garapati April 4, 2016, 9:11 a.m. UTC
Resolving https://bugs.linaro.org/show_bug.cgi?id=2136 by initializing
definite number of worker threads.

Signed-off-by: Balakrishna Garapati <balakrishna.garapati@linaro.org>
---
 test/performance/odp_crypto.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

--
1.9.1

Comments

Maxim Uvarov April 4, 2016, 7:53 p.m. UTC | #1
On 04/04/16 12:11, Balakrishna Garapati wrote:
> Resolving https://bugs.linaro.org/show_bug.cgi?id=2136 by initializing
> definite number of worker threads.
>
> Signed-off-by: Balakrishna Garapati <balakrishna.garapati@linaro.org>
> ---
>   test/performance/odp_crypto.c | 10 ++++++----
>   1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/test/performance/odp_crypto.c b/test/performance/odp_crypto.c
> index fe1c7b4..32b41ef 100644
> --- a/test/performance/odp_crypto.c
> +++ b/test/performance/odp_crypto.c
> @@ -719,12 +719,12 @@ int main(int argc, char *argv[])
>   	odp_pool_t pool;
>   	odp_queue_param_t qparam;
>   	odp_pool_param_t params;
> -	odph_linux_pthread_t thr;
>   	odp_queue_t out_queue = ODP_QUEUE_INVALID;
>   	thr_arg_t thr_arg;
> -	int num_workers = 1;
>   	odp_cpumask_t cpumask;
>   	char cpumaskstr[ODP_CPUMASK_STR_SIZE];
> +	int num_workers = 1;
> +	odph_linux_pthread_t thr[num_workers];
>
>   	memset(&cargs, 0, sizeof(cargs));
>
> @@ -793,13 +793,15 @@ int main(int argc, char *argv[])
>   		printf("Run in sync mode\n");
>   	}
>
> +	memset(thr, 0, sizeof(thr));
> +
>   	if (cargs.alg_config) {
>   		if (cargs.schedule) {
> -			odph_linux_pthread_create(&thr, &cpumask,
> +			odph_linux_pthread_create(&thr[0], &cpumask,
>   						  run_thr_func,
>   						  &thr_arg,
>   						  ODP_THREAD_WORKER);
> -			odph_linux_pthread_join(&thr, num_workers);
> +			odph_linux_pthread_join(thr, num_workers);
both create and join have the same first argument. Please write them the 
same in 2 places.

Maxim.

>   		} else {
>   			run_measure_one_config(&cargs, cargs.alg_config);
>   		}
> --
> 1.9.1
>
diff mbox

Patch

diff --git a/test/performance/odp_crypto.c b/test/performance/odp_crypto.c
index fe1c7b4..32b41ef 100644
--- a/test/performance/odp_crypto.c
+++ b/test/performance/odp_crypto.c
@@ -719,12 +719,12 @@  int main(int argc, char *argv[])
 	odp_pool_t pool;
 	odp_queue_param_t qparam;
 	odp_pool_param_t params;
-	odph_linux_pthread_t thr;
 	odp_queue_t out_queue = ODP_QUEUE_INVALID;
 	thr_arg_t thr_arg;
-	int num_workers = 1;
 	odp_cpumask_t cpumask;
 	char cpumaskstr[ODP_CPUMASK_STR_SIZE];
+	int num_workers = 1;
+	odph_linux_pthread_t thr[num_workers];

 	memset(&cargs, 0, sizeof(cargs));

@@ -793,13 +793,15 @@  int main(int argc, char *argv[])
 		printf("Run in sync mode\n");
 	}

+	memset(thr, 0, sizeof(thr));
+
 	if (cargs.alg_config) {
 		if (cargs.schedule) {
-			odph_linux_pthread_create(&thr, &cpumask,
+			odph_linux_pthread_create(&thr[0], &cpumask,
 						  run_thr_func,
 						  &thr_arg,
 						  ODP_THREAD_WORKER);
-			odph_linux_pthread_join(&thr, num_workers);
+			odph_linux_pthread_join(thr, num_workers);
 		} else {
 			run_measure_one_config(&cargs, cargs.alg_config);
 		}