diff options
author | Colin Cross | 2013-11-08 21:07:38 -0600 |
---|---|---|
committer | Colin Cross | 2013-12-18 20:27:57 -0600 |
commit | 7496318486da5a501cd8ab854c2e47ca56ea1ee3 (patch) | |
tree | b15185b98d08b335b07c7e26ed1491d4f6a6c5ec /libion | |
parent | 92d7ca6af3ee38027d7341f24c6b550eaa41417a (diff) | |
download | platform-system-core-7496318486da5a501cd8ab854c2e47ca56ea1ee3.tar.gz platform-system-core-7496318486da5a501cd8ab854c2e47ca56ea1ee3.tar.xz platform-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, | |||
65 | .flags = flags, | 65 | .flags = flags, |
66 | }; | 66 | }; |
67 | 67 | ||
68 | if (handle == NULL) | ||
69 | return -EINVAL; | ||
70 | |||
68 | ret = ion_ioctl(fd, ION_IOC_ALLOC, &data); | 71 | ret = ion_ioctl(fd, ION_IOC_ALLOC, &data); |
69 | if (ret < 0) | 72 | if (ret < 0) |
70 | return ret; | 73 | return ret; |
@@ -83,11 +86,17 @@ int ion_free(int fd, ion_user_handle_t handle) | |||
83 | int ion_map(int fd, ion_user_handle_t handle, size_t length, int prot, | 86 | int ion_map(int fd, ion_user_handle_t handle, size_t length, int prot, |
84 | int flags, off_t offset, unsigned char **ptr, int *map_fd) | 87 | int flags, off_t offset, unsigned char **ptr, int *map_fd) |
85 | { | 88 | { |
89 | int ret; | ||
86 | struct ion_fd_data data = { | 90 | struct ion_fd_data data = { |
87 | .handle = handle, | 91 | .handle = handle, |
88 | }; | 92 | }; |
89 | 93 | ||
90 | int ret = ion_ioctl(fd, ION_IOC_MAP, &data); | 94 | if (map_fd == NULL) |
95 | return -EINVAL; | ||
96 | if (ptr == NULL) | ||
97 | return -EINVAL; | ||
98 | |||
99 | ret = ion_ioctl(fd, ION_IOC_MAP, &data); | ||
91 | if (ret < 0) | 100 | if (ret < 0) |
92 | return ret; | 101 | return ret; |
93 | *map_fd = data.fd; | 102 | *map_fd = data.fd; |
@@ -106,11 +115,15 @@ int ion_map(int fd, ion_user_handle_t handle, size_t length, int prot, | |||
106 | int ion_share(int fd, ion_user_handle_t handle, int *share_fd) | 115 | int ion_share(int fd, ion_user_handle_t handle, int *share_fd) |
107 | { | 116 | { |
108 | int map_fd; | 117 | int map_fd; |
118 | int ret; | ||
109 | struct ion_fd_data data = { | 119 | struct ion_fd_data data = { |
110 | .handle = handle, | 120 | .handle = handle, |
111 | }; | 121 | }; |
112 | 122 | ||
113 | int ret = ion_ioctl(fd, ION_IOC_SHARE, &data); | 123 | if (share_fd == NULL) |
124 | return -EINVAL; | ||
125 | |||
126 | ret = ion_ioctl(fd, ION_IOC_SHARE, &data); | ||
114 | if (ret < 0) | 127 | if (ret < 0) |
115 | return ret; | 128 | return ret; |
116 | *share_fd = data.fd; | 129 | *share_fd = data.fd; |
@@ -136,11 +149,15 @@ int ion_alloc_fd(int fd, size_t len, size_t align, unsigned int heap_mask, | |||
136 | 149 | ||
137 | int ion_import(int fd, int share_fd, ion_user_handle_t *handle) | 150 | int ion_import(int fd, int share_fd, ion_user_handle_t *handle) |
138 | { | 151 | { |
152 | int ret; | ||
139 | struct ion_fd_data data = { | 153 | struct ion_fd_data data = { |
140 | .fd = share_fd, | 154 | .fd = share_fd, |
141 | }; | 155 | }; |
142 | 156 | ||
143 | int ret = ion_ioctl(fd, ION_IOC_IMPORT, &data); | 157 | if (handle == NULL) |
158 | return -EINVAL; | ||
159 | |||
160 | ret = ion_ioctl(fd, ION_IOC_IMPORT, &data); | ||
144 | if (ret < 0) | 161 | if (ret < 0) |
145 | return ret; | 162 | return ret; |
146 | *handle = data.handle; | 163 | *handle = data.handle; |