summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/ioctl_wrappers.c4
-rw-r--r--lib/ioctl_wrappers.h10
2 files changed, 12 insertions, 2 deletions
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 7b419ea6..ccc5ccf5 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -735,7 +735,7 @@ void *__gem_mmap__wc(int fd, uint32_t handle, uint64_t offset, uint64_t size, un
return NULL;
errno = 0;
- return (void *)(uintptr_t)arg.addr_ptr;
+ return from_user_pointer(arg.addr_ptr);
}
/**
@@ -782,7 +782,7 @@ void *__gem_mmap__cpu(int fd, uint32_t handle, uint64_t offset, uint64_t size, u
return NULL;
errno = 0;
- return (void *)(uintptr_t)mmap_arg.addr_ptr;
+ return from_user_pointer(mmap_arg.addr_ptr);
}
/**
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index f9507ad0..57ba5a29 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -250,4 +250,14 @@ static inline uint64_t to_user_pointer(const void *ptr)
return (uintptr_t)ptr;
}
+/**
+ * from_user_pointer:
+ *
+ * Casts a 64bit value from an ioctl into a pointer.
+ */
+static inline void *from_user_pointer(uint64_t u64)
+{
+ return (void *)(uintptr_t)u64;
+}
+
#endif /* IOCTL_WRAPPERS_H */