summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-06-19 15:34:09 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2012-06-19 15:34:09 +0100
commit2dc93b2a6c832ce8b972de90d09080e860dcd40f (patch)
treecfa22bfe5a61bb17bafcece473e04d3e5f82b54c
parent06634604abf15fdd27dd007fcf81595da994146b (diff)
sna: Check results from syscalls
Reported-by: Zdenek Kabelac <zkabelac@redhat.com> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/intel_driver.c5
-rw-r--r--src/sna/kgem.c7
-rw-r--r--src/sna/sna_driver.c14
-rw-r--r--src/sna/sna_video_overlay.c5
4 files changed, 24 insertions, 7 deletions
diff --git a/src/intel_driver.c b/src/intel_driver.c
index 3a9fe6f2..f1bb10d4 100644
--- a/src/intel_driver.c
+++ b/src/intel_driver.c
@@ -753,7 +753,10 @@ I830HandleUEvents(int fd, void *closure)
return;
udev_devnum = udev_device_get_devnum(dev);
- fstat(intel->drmSubFD, &s);
+ if (fstat(intel->drmSubFD, &s)) {
+ udev_device_unref(dev);
+ return;
+ }
/*
* Check to make sure this event is directed at our
* device (by comparing dev_t values), then make
diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 016ff48f..bb1b77d3 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -567,7 +567,8 @@ static int gem_param(struct kgem *kgem, int name)
VG_CLEAR(gp);
gp.param = name;
gp.value = &v;
- drmIoctl(kgem->fd, DRM_IOCTL_I915_GETPARAM, &gp);
+ if (drmIoctl(kgem->fd, DRM_IOCTL_I915_GETPARAM, &gp))
+ return -1;
VG(VALGRIND_MAKE_MEM_DEFINED(&v, sizeof(v)));
return v;
@@ -2129,7 +2130,9 @@ void kgem_cleanup_cache(struct kgem *kgem)
set_domain.handle = rq->bo->handle;
set_domain.read_domains = I915_GEM_DOMAIN_GTT;
set_domain.write_domain = I915_GEM_DOMAIN_GTT;
- drmIoctl(kgem->fd, DRM_IOCTL_I915_GEM_SET_DOMAIN, &set_domain);
+ (void)drmIoctl(kgem->fd,
+ DRM_IOCTL_I915_GEM_SET_DOMAIN,
+ &set_domain);
}
kgem_retire(kgem);
diff --git a/src/sna/sna_driver.c b/src/sna/sna_driver.c
index 76ae24ed..a02ff766 100644
--- a/src/sna/sna_driver.c
+++ b/src/sna/sna_driver.c
@@ -353,7 +353,7 @@ static int sna_open_drm_master(ScrnInfoPtr scrn)
/* make the fd nonblocking to handle event loops */
flags = fcntl(fd, F_GETFL, 0);
if (flags != -1)
- fcntl(fd, F_SETFL, flags | O_NONBLOCK);
+ (void)fcntl(fd, F_SETFL, flags | O_NONBLOCK);
dev->fd = fd;
dev->open_count = 1;
@@ -392,10 +392,14 @@ static bool has_pageflipping(struct sna *sna)
if (sna->flags & SNA_NO_WAIT)
return false;
+ v = 0;
+
VG_CLEAR(gp);
gp.param = I915_PARAM_HAS_PAGEFLIPPING;
gp.value = &v;
- drmIoctl(sna->kgem.fd, DRM_IOCTL_I915_GETPARAM, &gp);
+
+ if (drmIoctl(sna->kgem.fd, DRM_IOCTL_I915_GETPARAM, &gp))
+ return false;
VG(VALGRIND_MAKE_MEM_DEFINED(&v, sizeof(v)));
return v > 0;
@@ -625,7 +629,11 @@ sna_handle_uevents(int fd, void *closure)
return;
udev_devnum = udev_device_get_devnum(dev);
- fstat(sna->kgem.fd, &s);
+ if (fstat(sna->kgem.fd, &s)) {
+ udev_device_unref(dev);
+ return;
+ }
+
/*
* Check to make sure this event is directed at our
* device (by comparing dev_t values), then make
diff --git a/src/sna/sna_video_overlay.c b/src/sna/sna_video_overlay.c
index 612711f9..d47f7458 100644
--- a/src/sna/sna_video_overlay.c
+++ b/src/sna/sna_video_overlay.c
@@ -148,7 +148,10 @@ static void sna_video_overlay_off(struct sna *sna)
request.flags = 0;
- drmIoctl(sna->kgem.fd, DRM_IOCTL_I915_OVERLAY_PUT_IMAGE, &request);
+ /* Not much we can do if the hardware dies before we turn it off! */
+ (void)drmIoctl(sna->kgem.fd,
+ DRM_IOCTL_I915_OVERLAY_PUT_IMAGE,
+ &request);
}
static void sna_video_overlay_stop(ScrnInfoPtr scrn,