diff mbox

[PATCHv3] test: performance: Avoid possible out-of-bounds memory access

Message ID 1459924841-29611-1-git-send-email-balakrishna.garapati@linaro.org
State Accepted
Commit d7a9c93f997defcb73207dc63632ae9736012c1d
Headers show

Commit Message

Balakrishna Garapati April 6, 2016, 6:40 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>
---
 v1: Fix for the https://bugs.linaro.org/show_bug.cgi?id=2136
 v2: comments from v1
 v3: Adding commit message

 test/performance/odp_crypto.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

--
1.9.1

Comments

Balakrishna Garapati April 7, 2016, 10:06 a.m. UTC | #1
ping

On 6 April 2016 at 08:40, Balakrishna Garapati <
balakrishna.garapati@linaro.org> 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>

> ---

>  v1: Fix for the https://bugs.linaro.org/show_bug.cgi?id=2136

>  v2: comments from v1

>  v3: Adding commit message

>

>  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..0ea0b1b 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[0], num_workers);

>                 } else {

>                         run_measure_one_config(&cargs, cargs.alg_config);

>                 }

> --

> 1.9.1

>

>
Balasubramanian Manoharan April 11, 2016, 7:30 a.m. UTC | #2
Reviewed-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>


Regards,
Bala

On 6 April 2016 at 12:10, Balakrishna Garapati <
balakrishna.garapati@linaro.org> 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>

> ---

>  v1: Fix for the https://bugs.linaro.org/show_bug.cgi?id=2136

>  v2: comments from v1

>  v3: Adding commit message

>

>  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..0ea0b1b 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[0], num_workers);

>                 } else {

>                         run_measure_one_config(&cargs, cargs.alg_config);

>                 }

> --

> 1.9.1

>

>
Maxim Uvarov April 12, 2016, 8:56 a.m. UTC | #3
Merged,
Maxim.

On 04/11/16 10:30, Bala Manoharan wrote:
> Reviewed-by: Balasubramanian Manoharan <bala.manoharan@linaro.org 
> <mailto:bala.manoharan@linaro.org>>
>
> Regards,
> Bala
>
> On 6 April 2016 at 12:10, Balakrishna Garapati 
> <balakrishna.garapati@linaro.org 
> <mailto:balakrishna.garapati@linaro.org>> 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
>     <mailto:balakrishna.garapati@linaro.org>>
>     ---
>      v1: Fix for the https://bugs.linaro.org/show_bug.cgi?id=2136
>      v2: comments from v1
>      v3: Adding commit message
>
>      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..0ea0b1b 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[0], num_workers);
>                     } 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..0ea0b1b 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[0], num_workers);
 		} else {
 			run_measure_one_config(&cargs, cargs.alg_config);
 		}