[igt-dev] [PATCH i-g-t 12/21] benchmarks/gem_userptr_benchmark: Correctly free memory

Tvrtko Ursulin tvrtko.ursulin at linux.intel.com
Wed Jan 16 11:48:53 UTC 2019


On 16/01/2019 11:20, Petri Latvala wrote:
> if (p) free(p) does a useless check, free(NULL) is a valid call. Also
> assign NULL so we don't end up double-freeing memory if anyone
> reorders nr_bos to have a 0 after other values.
> 
> Signed-off-by: Petri Latvala <petri.latvala at intel.com>
> Cc: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> ---
>   benchmarks/gem_userptr_benchmark.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/benchmarks/gem_userptr_benchmark.c b/benchmarks/gem_userptr_benchmark.c
> index f7716dfa..bef2ccc4 100644
> --- a/benchmarks/gem_userptr_benchmark.c
> +++ b/benchmarks/gem_userptr_benchmark.c
> @@ -355,8 +355,9 @@ static void test_impact_overlap(int fd, const char *prefix)
>   
>   		for (i = 0; i < nr_bos[subtest]; i++)
>   			gem_close(fd, handles[i]);
> -		if (block)
> -			free(block);
> +
> +		free(block);
> +		block = NULL;
>   	}
>   }
>   
> 

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>

Regards,

Tvrtko


More information about the igt-dev mailing list