Commit a1c6b996 authored by Olav Haugan's avatar Olav Haugan Committed by Greg Kroah-Hartman

gpu: ion: IOCTL return success when error occurs

ION_IOC_MAP, ION_IOC_SHARE, and ION_IOC_IMPORT may return
success when an error occurs.

Add correct error handling to ION_IOC_MAP, ION_IOC_SHARE, and
ION_IOC_IMPORT.
Signed-off-by: default avatarOlav Haugan <ohaugan@codeaurora.org>
[jstultz: modified patch to apply to staging directory]
Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ee4c8aa9
...@@ -1040,20 +1040,27 @@ static long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) ...@@ -1040,20 +1040,27 @@ static long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
data.fd = ion_share_dma_buf(client, data.handle); data.fd = ion_share_dma_buf(client, data.handle);
if (copy_to_user((void __user *)arg, &data, sizeof(data))) if (copy_to_user((void __user *)arg, &data, sizeof(data)))
return -EFAULT; return -EFAULT;
if (data.fd < 0)
return data.fd;
break; break;
} }
case ION_IOC_IMPORT: case ION_IOC_IMPORT:
{ {
struct ion_fd_data data; struct ion_fd_data data;
int ret = 0;
if (copy_from_user(&data, (void __user *)arg, if (copy_from_user(&data, (void __user *)arg,
sizeof(struct ion_fd_data))) sizeof(struct ion_fd_data)))
return -EFAULT; return -EFAULT;
data.handle = ion_import_dma_buf(client, data.fd); data.handle = ion_import_dma_buf(client, data.fd);
if (IS_ERR(data.handle)) if (IS_ERR(data.handle)) {
ret = PTR_ERR(data.handle);
data.handle = NULL; data.handle = NULL;
}
if (copy_to_user((void __user *)arg, &data, if (copy_to_user((void __user *)arg, &data,
sizeof(struct ion_fd_data))) sizeof(struct ion_fd_data)))
return -EFAULT; return -EFAULT;
if (ret < 0)
return ret;
break; break;
} }
case ION_IOC_SYNC: case ION_IOC_SYNC:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment