[igt-dev] [PATCH i-g-t] chamelium: Fix analog bridge detection memory leak

Paul Kocialkowski paul.kocialkowski at bootlin.com
Wed Nov 14 15:29:18 UTC 2018


The connector and EDID blob retrieved when checking for analog bridges
need to be freed before returning from the associated function.

Fixes: f8d6afa67 ("tests/chamelium: Detect analog bridges and handle
EDID accordingly")
Signed-off-by: Paul Kocialkowski <paul.kocialkowski at bootlin.com>
---
 tests/kms_chamelium.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/tests/kms_chamelium.c b/tests/kms_chamelium.c
index e0e3e3f1..55b346a9 100644
--- a/tests/kms_chamelium.c
+++ b/tests/kms_chamelium.c
@@ -175,8 +175,10 @@ check_analog_bridge(data_t *data, struct chamelium_port *port)
 	unsigned char *edid;
 	char edid_vendor[3];
 
-	if (chamelium_port_get_type(port) != DRM_MODE_CONNECTOR_VGA)
+	if (chamelium_port_get_type(port) != DRM_MODE_CONNECTOR_VGA) {
+		drmModeFreeConnector(connector);
 		return false;
+	}
 
 	igt_assert(kmstest_get_property(data->drm_fd, connector->connector_id,
 					DRM_MODE_OBJECT_CONNECTOR, "EDID", NULL,
@@ -191,14 +193,14 @@ check_analog_bridge(data_t *data, struct chamelium_port *port)
 			  ((edid[9] & 0xe0) >> 5)) + '@';
 	edid_vendor[2] = (edid[9] & 0x1f) + '@';
 
+	drmModeFreePropertyBlob(edid_blob);
+	drmModeFreeConnector(connector);
+
 	/* Analog bridges provide their own EDID */
 	if (edid_vendor[0] != 'I' || edid_vendor[1] != 'G' ||
 	    edid_vendor[0] != 'T')
 		return true;
 
-	drmModeFreePropertyBlob(edid_blob);
-	drmModeFreeConnector(connector);
-
 	return false;
 }
 
-- 
2.19.1



More information about the igt-dev mailing list