diff options
author | Sundar Raman | 2013-06-03 13:19:31 -0500 |
---|---|---|
committer | Sundar Raman | 2013-07-26 15:59:21 -0500 |
commit | 5f1023048e35f0c6d89f0eb83c74866fa2cb54b2 (patch) | |
tree | f2283b3c00b4c3be91b457da6ef888c7f9f99392 | |
parent | 556a225979c47c011034707f49beced49a36829c (diff) | |
download | kernel-video-5f1023048e35f0c6d89f0eb83c74866fa2cb54b2.tar.gz kernel-video-5f1023048e35f0c6d89f0eb83c74866fa2cb54b2.tar.xz kernel-video-5f1023048e35f0c6d89f0eb83c74866fa2cb54b2.zip |
gpu: ion: omap: add checks for carveout addresses and sizes
This patch adds sanity checks on the carveout and size parameters
read from the device tree file and returns error. It also checks
if the device tree is populated and returns error accordingly.
Change-Id: Ic1f4e9d7c5f7e9361d9fe922544f9dbc105d99c3
Signed-off-by: Sundar Raman <a0393242@ti.com>
-rwxr-xr-x | drivers/gpu/ion/omap/omap_ion.c | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/drivers/gpu/ion/omap/omap_ion.c b/drivers/gpu/ion/omap/omap_ion.c index f3db9d7ca95..886dd6f8133 100755 --- a/drivers/gpu/ion/omap/omap_ion.c +++ b/drivers/gpu/ion/omap/omap_ion.c | |||
@@ -124,12 +124,6 @@ static int omap_ion_probe(struct platform_device *pdev) | |||
124 | uint omap_ion_heap_tiler_size = 0; | 124 | uint omap_ion_heap_tiler_size = 0; |
125 | uint omap_ion_heap_nonsecure_tiler_size = 0; | 125 | uint omap_ion_heap_nonsecure_tiler_size = 0; |
126 | 126 | ||
127 | omap_ion_device = ion_device_create(omap_ion_ioctl); | ||
128 | if (IS_ERR_OR_NULL(omap_ion_device)) { | ||
129 | kfree(heaps); | ||
130 | return PTR_ERR(omap_ion_device); | ||
131 | } | ||
132 | |||
133 | if (node) { | 127 | if (node) { |
134 | of_property_read_u32(node, "ti,omap_ion_heap_secure_input_base", | 128 | of_property_read_u32(node, "ti,omap_ion_heap_secure_input_base", |
135 | &omap_ion_heap_secure_input_base); | 129 | &omap_ion_heap_secure_input_base); |
@@ -137,6 +131,19 @@ static int omap_ion_probe(struct platform_device *pdev) | |||
137 | &omap_ion_heap_tiler_base); | 131 | &omap_ion_heap_tiler_base); |
138 | of_property_read_u32(node, "ti,omap_ion_heap_nonsecure_tiler_base", | 132 | of_property_read_u32(node, "ti,omap_ion_heap_nonsecure_tiler_base", |
139 | &omap_ion_heap_nonsecure_tiler_base); | 133 | &omap_ion_heap_nonsecure_tiler_base); |
134 | if (omap_ion_heap_secure_input_base == 0 | ||
135 | || omap_ion_heap_tiler_base == 0 | ||
136 | || omap_ion_heap_nonsecure_tiler_base == 0) { | ||
137 | pr_err("%s: carveout memory address is null. please check dts file\n" | ||
138 | "omap_ion_heap_secure_input_base = 0x%x\n" | ||
139 | "omap_ion_heap_tiler_base = 0x%x\n" | ||
140 | "omap_ion_heap_nonsecure_tiler_base = 0x%x\n" | ||
141 | , __func__ | ||
142 | , omap_ion_heap_secure_input_base | ||
143 | , omap_ion_heap_tiler_base | ||
144 | , omap_ion_heap_tiler_base); | ||
145 | return -EFAULT; | ||
146 | } | ||
140 | 147 | ||
141 | of_property_read_u32(node, "ti,omap_ion_heap_secure_input_size", | 148 | of_property_read_u32(node, "ti,omap_ion_heap_secure_input_size", |
142 | &omap_ion_heap_secure_input_size); | 149 | &omap_ion_heap_secure_input_size); |
@@ -144,8 +151,30 @@ static int omap_ion_probe(struct platform_device *pdev) | |||
144 | &omap_ion_heap_tiler_size); | 151 | &omap_ion_heap_tiler_size); |
145 | of_property_read_u32(node, "ti,omap_ion_heap_nonsecure_tiler_size", | 152 | of_property_read_u32(node, "ti,omap_ion_heap_nonsecure_tiler_size", |
146 | &omap_ion_heap_nonsecure_tiler_size); | 153 | &omap_ion_heap_nonsecure_tiler_size); |
154 | if (omap_ion_heap_secure_input_size == 0 | ||
155 | || omap_ion_heap_tiler_size == 0 | ||
156 | || omap_ion_heap_nonsecure_tiler_size == 0) { | ||
157 | pr_err("%s: carveout memory address is null. please check dts file\n" | ||
158 | "omap_ion_heap_secure_input_size = 0x%x\n" | ||
159 | "omap_ion_heap_tiler_size = 0x%x\n" | ||
160 | "omap_ion_heap_nonsecure_tiler_size = 0x%x\n" | ||
161 | , __func__ | ||
162 | , omap_ion_heap_secure_input_size | ||
163 | , omap_ion_heap_tiler_size | ||
164 | , omap_ion_heap_nonsecure_tiler_size); | ||
165 | return -EINVAL; | ||
166 | } | ||
167 | |||
168 | } else { | ||
169 | pr_err("%s: no matching device tree node\n", __func__); | ||
170 | return -ENODEV; | ||
147 | } | 171 | } |
148 | 172 | ||
173 | omap_ion_device = ion_device_create(omap_ion_ioctl); | ||
174 | if (IS_ERR_OR_NULL(omap_ion_device)) | ||
175 | return PTR_ERR(omap_ion_device); | ||
176 | |||
177 | |||
149 | num_heaps = omap_ion_data.nr; | 178 | num_heaps = omap_ion_data.nr; |
150 | 179 | ||
151 | heaps = kzalloc(sizeof(struct ion_heap *)*num_heaps, GFP_KERNEL); | 180 | heaps = kzalloc(sizeof(struct ion_heap *)*num_heaps, GFP_KERNEL); |
@@ -242,6 +271,7 @@ int omap_ion_share_fd_to_buffers(int fd, struct ion_buffer **buffers, | |||
242 | struct ion_handle **handles; | 271 | struct ion_handle **handles; |
243 | struct ion_client *client; | 272 | struct ion_client *client; |
244 | int i = 0, ret = 0; | 273 | int i = 0, ret = 0; |
274 | int share_fd; | ||
245 | 275 | ||
246 | handles = kzalloc(*num_handles * sizeof(struct ion_handle *), | 276 | handles = kzalloc(*num_handles * sizeof(struct ion_handle *), |
247 | GFP_KERNEL); | 277 | GFP_KERNEL); |