gpu: ion: Return negative value from ioctl on allocation failure
If the ion allocation fails, return a negative value to the
ioctl. This is easier for userspace to deal with than
checking if the handle is valid.
Change-Id: I1c785b1b1e71d2bd45c6f7be78ea15e4a08cd6e5
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
diff --git a/drivers/gpu/ion/ion.c b/drivers/gpu/ion/ion.c
index 5a596a0..50420ba 100644
--- a/drivers/gpu/ion/ion.c
+++ b/drivers/gpu/ion/ion.c
@@ -1093,6 +1093,10 @@
return -EFAULT;
data.handle = ion_alloc(client, data.len, data.align,
data.flags);
+
+ if (IS_ERR_OR_NULL(data.handle))
+ return PTR_ERR(data.handle);
+
if (copy_to_user((void __user *)arg, &data, sizeof(data)))
return -EFAULT;
break;