diff options
author | Russell King <rmk@armlinux.org.uk> | 2018-06-28 09:51:06 +0100 |
---|---|---|
committer | Russell King <rmk@armlinux.org.uk> | 2018-07-13 18:14:06 +0100 |
commit | d2ce88ab3f42d5ce74b81bc45ee19f2b64c0296d (patch) | |
tree | 2b78a7fbdd919a24dbbc50489393c5729783c428 | |
parent | a5671e6120c4b4ae46ff8d0285f0b1047d3000d1 (diff) |
src: clean up connector properties when destroying
Free the connector properties and associated memory when destroying
the connector to prevent memory leaks.
Signed-off-by: Russell King <rmk@armlinux.org.uk>
-rw-r--r-- | src/common_drm.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/common_drm.c b/src/common_drm.c index 0095813..b7b37e0 100644 --- a/src/common_drm.c +++ b/src/common_drm.c @@ -395,12 +395,23 @@ static Bool common_drm_conn_get_property(xf86OutputPtr output, Atom property) static void common_drm_conn_destroy(xf86OutputPtr output) { struct common_conn_info *conn = output->driver_private; + int i; - drmModeFreeProperty(conn->edid); - drmModeFreeProperty(conn->dpms); - drmModeFreeConnector(conn->mode_output); - drmModeFreeEncoder(conn->mode_encoder); - free(conn); + if (conn) { + if (conn->props) { + for (i = 0; i < conn->nprops; i++) { + if (conn->props[i].atoms) + free(conn->props[i].atoms); + drmModeFreeProperty(conn->props[i].mode_prop); + } + free(conn->props); + } + drmModeFreeProperty(conn->edid); + drmModeFreeProperty(conn->dpms); + drmModeFreeConnector(conn->mode_output); + drmModeFreeEncoder(conn->mode_encoder); + free(conn); + } output->driver_private = NULL; } |