diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2017-01-02 11:23:33 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2017-01-02 11:24:23 +0000 |
commit | 8f39310fa7484829f0899860b1677a0f75898edf (patch) | |
tree | 0f43fa939f255d831ab017c0f7ec7bbee5960d47 /lib | |
parent | 39858a1e752f8f26250171e8658388f0853c176c (diff) |
lib: Wrap conversion from u64 to pointers
The opposite direction of to_user_pointer() is from_user_pointer().
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ioctl_wrappers.c | 4 | ||||
-rw-r--r-- | lib/ioctl_wrappers.h | 10 |
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 */ |