[i-g-t,v3,15/21] lib/igt_chamelium: Fixup resources liberation in comparison helpers

Submitted by Paul Kocialkowski on Jan. 11, 2019, 9:05 a.m.

Details

Message ID 20190111090532.19235-16-paul.kocialkowski@bootlin.com
State Accepted
Commit fc85a9b16b73a51116d17468361e67a1f4e55592
Headers show
Series "Chamelium VC4 plane fuzzy testing, with SAND and T-tiled mode" ( rev: 1 ) in IGT

Not browsing as part of any series.

Commit Message

Paul Kocialkowski Jan. 11, 2019, 9:05 a.m.
This fixes a bunch of occurrences of memory not being properly
liberated after its use in helpers revolving around frame/CRC
comparison.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
 lib/igt_chamelium.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
index 32b859eac4a7..0b6ac37a3d89 100644
--- a/lib/igt_chamelium.c
+++ b/lib/igt_chamelium.c
@@ -1060,9 +1060,9 @@  void chamelium_assert_crc_eq_or_dump(struct chamelium *chamelium,
 		free(reference_suffix);
 		free(capture_suffix);
 
-		chamelium_destroy_frame_dump(frame);
-
+		cairo_surface_destroy(reference);
 		cairo_surface_destroy(capture);
+		chamelium_destroy_frame_dump(frame);
 	}
 
 	igt_assert(eq);
@@ -1120,11 +1120,14 @@  void chamelium_assert_analog_frame_match_or_dump(struct chamelium *chamelium,
 
 		free(reference_suffix);
 		free(capture_suffix);
+		free(reference_crc);
+		free(capture_crc);
 	}
 
-	cairo_surface_destroy(capture);
-
 	igt_assert(match);
+
+	cairo_surface_destroy(reference);
+	cairo_surface_destroy(capture);
 }
 
 
@@ -1323,6 +1326,8 @@  igt_crc_t *chamelium_calculate_fb_crc(int fd, struct igt_fb *fb)
 
 	chamelium_do_calculate_fb_crc(fb_surface, ret);
 
+	cairo_surface_destroy(fb_surface);
+
 	return ret;
 }
 

Comments

On Fri, Jan 11, 2019 at 10:05:26AM +0100, Paul Kocialkowski wrote:
> This fixes a bunch of occurrences of memory not being properly
> liberated after its use in helpers revolving around frame/CRC
> comparison.
> 
> Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>

Reviewed-by: Maxime Ripard <maxime.ripard@bootlin.com>

Maxime
Nice catch here!

Reviewed-by: Lyude Paul <lyude@redhat.com>

On Fri, 2019-01-11 at 10:05 +0100, Paul Kocialkowski wrote:
> This fixes a bunch of occurrences of memory not being properly
> liberated after its use in helpers revolving around frame/CRC
> comparison.
> 
> Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> ---
>  lib/igt_chamelium.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
> index 32b859eac4a7..0b6ac37a3d89 100644
> --- a/lib/igt_chamelium.c
> +++ b/lib/igt_chamelium.c
> @@ -1060,9 +1060,9 @@ void chamelium_assert_crc_eq_or_dump(struct chamelium
> *chamelium,
>  		free(reference_suffix);
>  		free(capture_suffix);
>  
> -		chamelium_destroy_frame_dump(frame);
> -
> +		cairo_surface_destroy(reference);
>  		cairo_surface_destroy(capture);
> +		chamelium_destroy_frame_dump(frame);
>  	}
>  
>  	igt_assert(eq);
> @@ -1120,11 +1120,14 @@ void
> chamelium_assert_analog_frame_match_or_dump(struct chamelium *chamelium,
>  
>  		free(reference_suffix);
>  		free(capture_suffix);
> +		free(reference_crc);
> +		free(capture_crc);
>  	}
>  
> -	cairo_surface_destroy(capture);
> -
>  	igt_assert(match);
> +
> +	cairo_surface_destroy(reference);
> +	cairo_surface_destroy(capture);
>  }
>  
>  
> @@ -1323,6 +1326,8 @@ igt_crc_t *chamelium_calculate_fb_crc(int fd, struct
> igt_fb *fb)
>  
>  	chamelium_do_calculate_fb_crc(fb_surface, ret);
>  
> +	cairo_surface_destroy(fb_surface);
> +
>  	return ret;
>  }
>