diff options
author | Hans de Goede <[email protected]> | 2016-05-07 14:43:59 +0200 |
---|---|---|
committer | Hans de Goede <[email protected]> | 2016-06-28 12:29:54 +0200 |
commit | 459cc94507071eec18b746f57a4ec82578a38b54 (patch) | |
tree | c2cebc74d2751721cbe36c258fa723556b351b7e /src/gallium/auxiliary | |
parent | 87787e907929fe65d6b65d467ad05ea94279bb5a (diff) |
pipe_loader_sw: Fix fd leak when instantiated via pipe_loader_sw_probe_kms
Make pipe_loader_sw_probe_kms take ownership of the passed in fd,
like pipe_loader_drm_probe_fd does.
The only caller is dri_kms_init_screen which passes in a dupped fd,
just like dri2_init_screen passes in a dupped fd to
pipe_loader_drm_probe_fd.
Signed-off-by: Hans de Goede <[email protected]>
Reviewed-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r-- | src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c index c8e1f134c99..e7fa974e419 100644 --- a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c +++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c @@ -45,6 +45,7 @@ struct pipe_loader_sw_device { struct util_dl_library *lib; #endif struct sw_winsys *ws; + int fd; }; #define pipe_loader_sw_device(dev) ((struct pipe_loader_sw_device *)dev) @@ -92,6 +93,7 @@ pipe_loader_sw_probe_init_common(struct pipe_loader_sw_device *sdev) sdev->base.type = PIPE_LOADER_DEVICE_SOFTWARE; sdev->base.driver_name = "swrast"; sdev->base.ops = &pipe_loader_sw_ops; + sdev->fd = -1; #ifdef GALLIUM_STATIC_TARGETS sdev->dd = &driver_descriptors; @@ -169,6 +171,8 @@ pipe_loader_sw_probe_kms(struct pipe_loader_device **devs, int fd) if (!pipe_loader_sw_probe_init_common(sdev)) goto fail; + sdev->fd = fd; + for (i = 0; sdev->dd->winsys[i].name; i++) { if (strcmp(sdev->dd->winsys[i].name, "kms_dri") == 0) { sdev->ws = sdev->dd->winsys[i].create_winsys(fd); @@ -273,6 +277,9 @@ pipe_loader_sw_release(struct pipe_loader_device **dev) util_dl_close(sdev->lib); #endif + if (sdev->fd != -1) + close(sdev->fd); + FREE(sdev); *dev = NULL; } |