[Ocfs2-test-devel] [PATCH 43/59] aio-stress: fix invalid parameter to pthread_join

Eric Ren zren at suse.com
Tue Sep 22 22:17:28 PDT 2015


Reviewed-by: Eric Ren <zren at suse.com>

Thanks,
Eric Ren

On Mon, Sep 14, 2015 at 10:44:29AM +0800, Junxiao Bi wrote: 
> The second parameter of pthread_join "value_ptr" has type "void **",
> but "void *" is passed in, if pthread_join access "**value_ptr", it
> will wrote into the value pointed by the content of "thread_ret" which
> is a random value and may cause segment fault. Since "thread_ret" is not
> used, so set the parameter to NULL.
> 
> Signed-off-by: Junxiao Bi <junxiao.bi at oracle.com>
> ---
>  programs/aio-stress/aio-stress.c |    3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/programs/aio-stress/aio-stress.c b/programs/aio-stress/aio-stress.c
> index 91af264..112ecf9 100644
> --- a/programs/aio-stress/aio-stress.c
> +++ b/programs/aio-stress/aio-stress.c
> @@ -1213,7 +1213,6 @@ typedef void * (*start_routine)(void *);
>  int run_workers(struct thread_info *t, int num_threads)
>  {
>      int ret;
> -    int thread_ret;
>      int i;
>  
>      for(i = 0 ; i < num_threads ; i++) {
> @@ -1224,7 +1223,7 @@ int run_workers(struct thread_info *t, int num_threads)
>  	}
>      }
>      for(i = 0 ; i < num_threads ; i++) {
> -        ret = pthread_join(t[i].tid, (void *)&thread_ret);
> +        ret = pthread_join(t[i].tid, NULL);
>          if (ret) {
>  	    perror("pthread_join");
>  	    exit(1);
> -- 
> 1.7.9.5
> 
> 
> _______________________________________________
> Ocfs2-test-devel mailing list
> Ocfs2-test-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/ocfs2-test-devel
> 



More information about the Ocfs2-test-devel mailing list