aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/xa
diff options
context:
space:
mode:
authorEmil Velikov <[email protected]>2018-08-29 18:13:14 +0100
committerEmil Velikov <[email protected]>2018-10-03 13:38:05 +0100
commit6ccc435e7ad92bb0ba77d3fdb48c7127ba71239e (patch)
tree6ca059b425d4b452bcfe76a634d4d852bed0f6d8 /src/gallium/state_trackers/xa
parent7b8d1b313cd01bb916898d8bb92a566534e37677 (diff)
pipe-loader: move dup(fd) within pipe_loader_drm_probe_fd
Currently pipe_loader_drm_probe_fd takes ownership of the fd given. To match that, pipe_loader_release closes it. Yet we have many instances which do not want the change of ownership, and thus duplicate the fd before passing it to the pipe-loader. Move the dup() within pipe-loader, explicitly document that and document all the cases through the codebase. A trivial git grep -2 pipe_loader_release makes things as obvious as it gets ;-) Cc: Leo Liu <[email protected]> Cc: Thomas Hellstrom <[email protected]> Cc: Axel Davy <[email protected]> Cc: Patrick Rudolph <[email protected]> Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Thomas Hellstrom <[email protected]> Reviewed-by: Axel Davy <[email protected]> (for nine)
Diffstat (limited to 'src/gallium/state_trackers/xa')
-rw-r--r--src/gallium/state_trackers/xa/xa_tracker.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/gallium/state_trackers/xa/xa_tracker.c b/src/gallium/state_trackers/xa/xa_tracker.c
index c046a3a7097..d07cd146af9 100644
--- a/src/gallium/state_trackers/xa/xa_tracker.c
+++ b/src/gallium/state_trackers/xa/xa_tracker.c
@@ -27,7 +27,6 @@
*/
#include <unistd.h>
-#include <fcntl.h>
#include "xa_tracker.h"
#include "xa_priv.h"
#include "pipe/p_state.h"
@@ -153,15 +152,11 @@ xa_tracker_create(int drm_fd)
struct xa_tracker *xa = calloc(1, sizeof(struct xa_tracker));
enum xa_surface_type stype;
unsigned int num_formats;
- int fd;
if (!xa)
return NULL;
- if (drm_fd < 0 || (fd = fcntl(drm_fd, F_DUPFD_CLOEXEC, 3)) < 0)
- goto out_no_fd;
-
- if (pipe_loader_drm_probe_fd(&xa->dev, fd))
+ if (pipe_loader_drm_probe_fd(&xa->dev, drm_fd))
xa->screen = pipe_loader_create_screen(xa->dev);
if (!xa->screen)
@@ -213,9 +208,7 @@ xa_tracker_create(int drm_fd)
out_no_screen:
if (xa->dev)
pipe_loader_release(&xa->dev, 1);
- else
- close(fd);
- out_no_fd:
+
free(xa);
return NULL;
}
@@ -227,6 +220,7 @@ xa_tracker_destroy(struct xa_tracker *xa)
xa_context_destroy(xa->default_ctx);
xa->screen->destroy(xa->screen);
pipe_loader_release(&xa->dev, 1);
+ /* CHECK: The XA API user preserves ownership of the original fd */
free(xa);
}