intel: Don't leak the test page in an has_userptr() error path
authorDamien Lespiau <damien.lespiau@intel.com>
Wed, 17 Sep 2014 12:33:45 +0000 (13:33 +0100)
committerDamien Lespiau <damien.lespiau@intel.com>
Fri, 19 Sep 2014 13:36:35 +0000 (14:36 +0100)
When handling the error on GEM_CLOSE, we weren't freeing the allocated
page. Plug that.

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
intel/intel_bufmgr_gem.c

index 35b42cf..ba65527 100644 (file)
@@ -3403,9 +3403,8 @@ retry:
 
        close_bo.handle = userptr.handle;
        ret = drmIoctl(bufmgr_gem->fd, DRM_IOCTL_GEM_CLOSE, &close_bo);
-       if (ret == 0) {
-               free(ptr);
-       } else {
+       free(ptr);
+       if (ret) {
                fprintf(stderr, "Failed to release test userptr object! (%d) "
                                "i915 kernel driver may not be sane!\n", errno);
                return false;