diff mbox

Check that the drm fd is i915 before calling i915 ioctls on it

Message ID 1345480034-20847-1-git-send-email-ajax@redhat.com (mailing list archive)
State Superseded
Headers show

Commit Message

Adam Jackson Aug. 20, 2012, 4:27 p.m. UTC
Signed-off-by: Adam Jackson <ajax@redhat.com>
---
 src/intel_module.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/src/intel_module.c b/src/intel_module.c
index edea48d..be9688a 100644
--- a/src/intel_module.c
+++ b/src/intel_module.c
@@ -392,11 +392,17 @@  static Bool has_kernel_mode_setting(struct pci_device *dev)
 	ret = FALSE;
 	fd = drmOpen(NULL, id);
 	if (fd != -1) {
-		struct drm_i915_getparam gp;
+		drmVersionPtr v;
 
-		gp.param = I915_PARAM_HAS_GEM;
-		gp.value = &ret;
-		(void)drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+		v = drmGetVersion(fd);
+		if (v && !strcmp(v->name, "i915")) {
+			struct drm_i915_getparam gp;
+
+			gp.param = I915_PARAM_HAS_GEM;
+			gp.value = &ret;
+			(void)drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+		}
+		drmFreeVersion(v);
 		close(fd);
 	}