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 <hdegoede@redhat.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
struct util_dl_library *lib;
#endif
struct sw_winsys *ws;
+ int fd;
};
#define pipe_loader_sw_device(dev) ((struct pipe_loader_sw_device *)dev)
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;
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);
util_dl_close(sdev->lib);
#endif
+ if (sdev->fd != -1)
+ close(sdev->fd);
+
FREE(sdev);
*dev = NULL;
}