diff options
author | Colin Cross <ccross@android.com> | 2013-11-08 19:07:38 -0800 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2013-12-18 18:27:57 -0800 |
commit | 7496318486da5a501cd8ab854c2e47ca56ea1ee3 (patch) | |
tree | b15185b98d08b335b07c7e26ed1491d4f6a6c5ec /libion | |
parent | 92d7ca6af3ee38027d7341f24c6b550eaa41417a (diff) | |
download | system_core-7496318486da5a501cd8ab854c2e47ca56ea1ee3.tar.gz system_core-7496318486da5a501cd8ab854c2e47ca56ea1ee3.tar.bz2 system_core-7496318486da5a501cd8ab854c2e47ca56ea1ee3.zip |
libion: add NULL checks
Check for NULL in any library function that takes a pointer.
Change-Id: I9ae8887b5ae0f231583173ee6a9dfd2f8c4611ec
Diffstat (limited to 'libion')
-rw-r--r-- | libion/ion.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/libion/ion.c b/libion/ion.c index ea40245f7..985094925 100644 --- a/libion/ion.c +++ b/libion/ion.c @@ -65,6 +65,9 @@ int ion_alloc(int fd, size_t len, size_t align, unsigned int heap_mask, .flags = flags, }; + if (handle == NULL) + return -EINVAL; + ret = ion_ioctl(fd, ION_IOC_ALLOC, &data); if (ret < 0) return ret; @@ -83,11 +86,17 @@ int ion_free(int fd, ion_user_handle_t handle) int ion_map(int fd, ion_user_handle_t handle, size_t length, int prot, int flags, off_t offset, unsigned char **ptr, int *map_fd) { + int ret; struct ion_fd_data data = { .handle = handle, }; - int ret = ion_ioctl(fd, ION_IOC_MAP, &data); + if (map_fd == NULL) + return -EINVAL; + if (ptr == NULL) + return -EINVAL; + + ret = ion_ioctl(fd, ION_IOC_MAP, &data); if (ret < 0) return ret; *map_fd = data.fd; @@ -106,11 +115,15 @@ int ion_map(int fd, ion_user_handle_t handle, size_t length, int prot, int ion_share(int fd, ion_user_handle_t handle, int *share_fd) { int map_fd; + int ret; struct ion_fd_data data = { .handle = handle, }; - int ret = ion_ioctl(fd, ION_IOC_SHARE, &data); + if (share_fd == NULL) + return -EINVAL; + + ret = ion_ioctl(fd, ION_IOC_SHARE, &data); if (ret < 0) return ret; *share_fd = data.fd; @@ -136,11 +149,15 @@ int ion_alloc_fd(int fd, size_t len, size_t align, unsigned int heap_mask, int ion_import(int fd, int share_fd, ion_user_handle_t *handle) { + int ret; struct ion_fd_data data = { .fd = share_fd, }; - int ret = ion_ioctl(fd, ION_IOC_IMPORT, &data); + if (handle == NULL) + return -EINVAL; + + ret = ion_ioctl(fd, ION_IOC_IMPORT, &data); if (ret < 0) return ret; *handle = data.handle; |