[igt-dev] [PATCH i-g-t 01/12] lib/igt_fb: Make igt_remove_fb more robust

Mika Kahola mika.kahola at intel.com
Wed Feb 7 13:39:03 UTC 2018


On Tue, 2018-02-06 at 11:14 +0100, Maarten Lankhorst wrote:
> This will make it easier for tests to unconditionally call
> igt_remove_fb, without first checking whether the FB is allocated.
> 

Reviewed-by: Mika Kahola <mika.kahola at intel.com>

> Signed-off-by: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
> ---
>  lib/igt_fb.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/lib/igt_fb.c b/lib/igt_fb.c
> index 6fecdd6699a5..35a928b9281d 100644
> --- a/lib/igt_fb.c
> +++ b/lib/igt_fb.c
> @@ -1623,9 +1623,13 @@ void igt_put_cairo_ctx(int fd, struct igt_fb
> *fb, cairo_t *cr)
>   */
>  void igt_remove_fb(int fd, struct igt_fb *fb)
>  {
> +	if (!fb || !fb->fb_id)
> +		return;
> +
>  	cairo_surface_destroy(fb->cairo_surface);
>  	do_or_die(drmModeRmFB(fd, fb->fb_id));
>  	gem_close(fd, fb->gem_handle);
> +	fb->fb_id = 0;
>  }
>  
>  /**
-- 
Mika Kahola - Intel OTC



More information about the igt-dev mailing list