From: Olav Haugan Date: Tue, 15 May 2012 21:40:11 +0000 (-0700) Subject: gpu: ion: IOCTL return success when error occurs X-Git-Tag: firefly_0821_release~4090^2~700 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=f10e9afc78a864208a01cd33557d114efa121ce4;p=firefly-linux-kernel-4.4.55.git 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. Change-Id: I61c6b0c574da425604235b2d39e13e4a27f7b6f3 Signed-off-by: Olav Haugan --- diff --git a/drivers/gpu/ion/ion.c b/drivers/gpu/ion/ion.c index d9460010b092..abfe15c87458 100644 --- a/drivers/gpu/ion/ion.c +++ b/drivers/gpu/ion/ion.c @@ -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); if (copy_to_user((void __user *)arg, &data, sizeof(data))) return -EFAULT; + if (data.fd < 0) + return data.fd; break; } case ION_IOC_IMPORT: { struct ion_fd_data data; + int ret = 0; if (copy_from_user(&data, (void __user *)arg, sizeof(struct ion_fd_data))) return -EFAULT; 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; + } if (copy_to_user((void __user *)arg, &data, sizeof(struct ion_fd_data))) return -EFAULT; + if (ret < 0) + return ret; break; } case ION_IOC_SYNC: