[igt-dev] [PATCH i-g-t v3 2/2] tests/kms_concurrent: Plug possible memory leaks

Lisovskiy, Stanislav stanislav.lisovskiy at intel.com
Fri Mar 27 08:01:42 UTC 2020


On Thu, Mar 26, 2020 at 03:53:22PM +0200, Mika Kahola wrote:
> Free dynamically allocated memory that has a potential
> to leak memory.
> 
> Signed-off-by: Mika Kahola <mika.kahola at intel.com>
> ---
>  tests/kms_concurrent.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 

TBH dynamically allocating memory here seems to be overkill
anyway. We already know for sure that max planes that we are going
to have is no more than 8, We could just set limit of max planes to
lets say even 10 and just do all this stuff in stack, thus avoiding
those issues.

Reviewed-by: Stanislav Lisovskiy <stanislav.lisovskiy at intel.com>

> diff --git a/tests/kms_concurrent.c b/tests/kms_concurrent.c
> index 1a7c12fc..1403e990 100644
> --- a/tests/kms_concurrent.c
> +++ b/tests/kms_concurrent.c
> @@ -193,6 +193,10 @@ prepare_planes(data_t *data, enum pipe pipe, int max_planes,
>  				    max_planes, output);
>  
>  	igt_plane_set_fb(data->plane[primary->index], &data->fb[primary->index]);
> +
> +	free(x);
> +	free(y);
> +	free(size);
>  }
>  
>  static int test_bandwidth(data_t *data, enum pipe pipe, igt_output_t *output)
> @@ -228,6 +232,10 @@ test_plane_position_with_output(data_t *data, enum pipe pipe, int max_planes,
>  	while (i < iterations || loop_forever) {
>  		prepare_planes(data, pipe, max_planes, output);
>  		igt_display_commit2(&data->display, COMMIT_ATOMIC);
> +
> +		for (int c = 0; c < max_planes; c++)
> +			igt_remove_fb(data->drm_fd, &data->fb[c]);
> +
>  		i++;
>  	}
>  }
> -- 
> 2.20.1
> 


More information about the igt-dev mailing list