From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Cc: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t] kms_dp_tiled_display: Fix the double free of drmConnector
Date: Wed, 18 Sep 2019 16:16:28 +0100 [thread overview]
Message-ID: <20190918151628.9880-1-chris@chris-wilson.co.uk> (raw)
drmConnectorFree is called inside the loop and after. Not unsurprisingly
this leads to a use-after-free and memcorruption.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=111710
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Manasi Navare <manasi.d.navare@intel.com>
---
tests/kms_dp_tiled_display.c | 28 ++++++++++------------------
1 file changed, 10 insertions(+), 18 deletions(-)
diff --git a/tests/kms_dp_tiled_display.c b/tests/kms_dp_tiled_display.c
index c4643c358..dc4866d2f 100644
--- a/tests/kms_dp_tiled_display.c
+++ b/tests/kms_dp_tiled_display.c
@@ -100,37 +100,29 @@ cleanup:
static void get_number_of_h_tiles(data_t *data)
{
- int i;
+ igt_tile_info_t tile = {};
drmModeResPtr res;
- drmModeConnectorPtr connector;
- igt_tile_info_t tile = {.num_h_tile = 0};
igt_assert(res = drmModeGetResources(data->drm_fd));
- for (i = 0; i < res->count_connectors; i++) {
+ for (int i = 0; !data->num_h_tiles && i < res->count_connectors; i++) {
+ drmModeConnectorPtr connector;
+
connector = drmModeGetConnectorCurrent(data->drm_fd,
res->connectors[i]);
-
igt_assert(connector);
- if (connector->connection != DRM_MODE_CONNECTED ||
- connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort) {
- drmModeFreeConnector(connector);
- continue;
- }
-
- get_connector_tile_props(data, connector, &tile);
+ if (connector->connection == DRM_MODE_CONNECTED &&
+ connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) {
+ get_connector_tile_props(data, connector, &tile);
- if (tile.num_h_tile == 0) {
- drmModeFreeConnector(connector);
- continue;
+ data->num_h_tiles = tile.num_h_tile;
}
- data->num_h_tiles = tile.num_h_tile;
- break;
+
+ drmModeFreeConnector(connector);
}
drmModeFreeResources(res);
- drmModeFreeConnector(connector);
}
static void get_connectors(data_t *data)
--
2.23.0
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next reply other threads:[~2019-09-18 15:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-18 15:16 Chris Wilson [this message]
2019-09-18 16:00 ` [igt-dev] ✓ Fi.CI.BAT: success for kms_dp_tiled_display: Fix the double free of drmConnector Patchwork
2019-09-18 16:38 ` [igt-dev] [PATCH i-g-t] " Manasi Navare
2019-09-19 3:54 ` [igt-dev] ✓ Fi.CI.IGT: success for " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190918151628.9880-1-chris@chris-wilson.co.uk \
--to=chris@chris-wilson.co.uk \
--cc=igt-dev@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox