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

Tvrtko Ursulin
2019-01-16T11:48:53Z

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@intel.com>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@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@intel.com>

Regards,

Tvrtko