[igt-dev] [PATCH i-g-t 2/3] lib/igt_chamelium: Duplicate the caller's drm_fd
Imre Deak
imre.deak at intel.com
Tue Jul 7 13:18:13 UTC 2020
Take a copy of the caller's FD so that the Chamelium lib functions can
access the DRM file regardless of when the caller closes its own FD.
This is needed at least by the next patch.
Cc: Lyude Paul <lyude at redhat.com>
Cc: Kunal Joshi <kunal1.joshi at intel.com>
Signed-off-by: Imre Deak <imre.deak at intel.com>
---
lib/igt_chamelium.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
index 5924e5615..90a2d04bb 100644
--- a/lib/igt_chamelium.c
+++ b/lib/igt_chamelium.c
@@ -2485,7 +2485,7 @@ struct chamelium *chamelium_init(int drm_fd)
if (cleanup_instance)
chamelium_deinit(cleanup_instance);
- chamelium->drm_fd = drm_fd;
+ chamelium->drm_fd = dup(drm_fd);
IGT_INIT_LIST_HEAD(&chamelium->edids);
if (!chamelium_read_port_mappings(chamelium, drm_fd))
@@ -2511,6 +2511,8 @@ struct chamelium *chamelium_init(int drm_fd)
return chamelium;
error:
+ close(chamelium->drm_fd);
+
chamelium_deinit_rpc_only(chamelium);
return NULL;
@@ -2550,6 +2552,8 @@ void chamelium_deinit(struct chamelium *chamelium)
free(pos);
}
+ close(chamelium->drm_fd);
+
xmlrpc_client_destroy(chamelium->client);
for (i = 0; i < chamelium->port_count; i++)
--
2.23.1
More information about the igt-dev
mailing list