[COMMON] staging: android: ion_test: fix copying incorrect size to userspace
authorCho KyongHo <pullip.cho@samsung.com>
Fri, 9 Jun 2017 13:53:47 +0000 (22:53 +0900)
committerSangwook Ju <sw.ju@samsung.com>
Mon, 14 May 2018 10:45:22 +0000 (19:45 +0900)
ion_test_ioctl() copies the data to userspace if ioctl command
includes read property. But it copies incorrect number of bytes
because 'data' in sizeof(data) is union of various length data
structures.

Change-Id: I3bcafa6823a38b8ce949f90086dbc9f4c5d3e8c3
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
drivers/staging/android/ion/ion_test.c

index 5abf8320a96aaae2387fdf7e42f5a9a85da0567b..05673eb46de280972e6fac5330bb823ee2e85787 100644 (file)
@@ -200,7 +200,7 @@ static long ion_test_ioctl(struct file *filp, unsigned int cmd,
        }
 
        if (_IOC_DIR(cmd) & _IOC_READ) {
-               if (copy_to_user((void __user *)arg, &data, sizeof(data)))
+               if (copy_to_user((void __user *)arg, &data, _IOC_SIZE(cmd)))
                        return -EFAULT;
        }
        return ret;