diff mbox

lib/igt_kms: Fix regression on kms_plane_lowres test

Message ID 1487253998-27550-1-git-send-email-mika.kahola@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Kahola, Mika Feb. 16, 2017, 2:06 p.m. UTC
kms_plane_lowres subtest pipe-C-tiling-none crashes when reading out
number of crtc. This patch fixes the bug on crtc readout.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99653
Fixes: 9de635976c426b4c835083792c7d4d6e32aec615
       ("lib/igt_kms: Avoid depencency on static plane count")

Signed-off-by: Mika Kahola <mika.kahola@intel.com>
---
 lib/igt_kms.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

Comments

Robert Foss Feb. 16, 2017, 7:10 p.m. UTC | #1
Applied and tested patch.

Reviewed-by: Robert Foss <robert.foss@collabora.com>

On 2017-02-16 09:06 AM, Mika Kahola wrote:
> kms_plane_lowres subtest pipe-C-tiling-none crashes when reading out
> number of crtc. This patch fixes the bug on crtc readout.
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99653
> Fixes: 9de635976c426b4c835083792c7d4d6e32aec615
>        ("lib/igt_kms: Avoid depencency on static plane count")
>
> Signed-off-by: Mika Kahola <mika.kahola@intel.com>
> ---
>  lib/igt_kms.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index dae8bf9..5388a83 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -1331,6 +1331,7 @@ void kmstest_get_crtc(enum pipe pipe, struct kmstest_crtc *crtc)
>  	const char *mode = "r";
>  	int ncrtc;
>  	int line;
> +	long int n;
>
>  	fid = igt_debugfs_fopen("i915_display_info", mode);
>
> @@ -1344,18 +1342,20 @@ void kmstest_get_crtc(enum pipe pipe, struct kmstest_crtc *crtc)
>  				crtc->active = true;
>  				parse_crtc(tmp, crtc);
>
> +				n = ftell(fid);
>  				crtc->n_planes = parse_planes(fid, NULL);
>  				crtc->planes = calloc(crtc->n_planes, sizeof(*crtc->planes));
>  				igt_assert_f(crtc->planes, "Failed to allocate memory for %d planes\n", crtc->n_planes);
>
> -				fseek(fid, 0, SEEK_END);
> -				fseek(fid, 0, SEEK_SET);
> +				fseek(fid, n, SEEK_SET);
>  				parse_planes(fid, crtc->planes);
>
> -				if (crtc->pipe != pipe)
> -					crtc = NULL;
> -				else
> +				if (crtc->pipe != pipe) {
> +					free(crtc->planes);
> +				} else {
>  					ncrtc++;
> +					break;
> +				}
>  			}
>  		}
>
>
diff mbox

Patch

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index dae8bf9..5388a83 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1331,6 +1331,7 @@  void kmstest_get_crtc(enum pipe pipe, struct kmstest_crtc *crtc)
 	const char *mode = "r";
 	int ncrtc;
 	int line;
+	long int n;
 
 	fid = igt_debugfs_fopen("i915_display_info", mode);
 
@@ -1344,18 +1342,20 @@  void kmstest_get_crtc(enum pipe pipe, struct kmstest_crtc *crtc)
 				crtc->active = true;
 				parse_crtc(tmp, crtc);
 
+				n = ftell(fid);
 				crtc->n_planes = parse_planes(fid, NULL);
 				crtc->planes = calloc(crtc->n_planes, sizeof(*crtc->planes));
 				igt_assert_f(crtc->planes, "Failed to allocate memory for %d planes\n", crtc->n_planes);
 
-				fseek(fid, 0, SEEK_END);
-				fseek(fid, 0, SEEK_SET);
+				fseek(fid, n, SEEK_SET);
 				parse_planes(fid, crtc->planes);
 
-				if (crtc->pipe != pipe)
-					crtc = NULL;
-				else
+				if (crtc->pipe != pipe) {
+					free(crtc->planes);
+				} else {
 					ncrtc++;
+					break;
+				}
 			}
 		}