]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
drm: fixup some of the ioctl function exit paths
authorDave Airlie <airlied@redhat.com>
Thu, 7 Feb 2008 04:51:32 +0000 (14:51 +1000)
committerDave Airlie <airlied@redhat.com>
Thu, 7 Feb 2008 05:12:00 +0000 (15:12 +1000)
Signed-off-by: Dave Airlie <airlied@linux.ie>
drivers/char/drm/drm_drv.c

index 77e2fb7b7b3707be0eec8a8d892c7cd16c9463df..0e7af53c87deda41d66e61957732b64586d1391d 100644 (file)
@@ -495,23 +495,25 @@ int drm_ioctl(struct inode *inode, struct file *filp,
        } else {
                if (cmd & (IOC_IN | IOC_OUT)) {
                        kdata = kmalloc(_IOC_SIZE(cmd), GFP_KERNEL);
-                       if (!kdata)
-                               return -ENOMEM;
+                       if (!kdata) {
+                               retcode = -ENOMEM;
+                               goto err_i1;
+                       }
                }
 
                if (cmd & IOC_IN) {
                        if (copy_from_user(kdata, (void __user *)arg,
                                           _IOC_SIZE(cmd)) != 0) {
-                               retcode = -EACCES;
+                               retcode = -EFAULT;
                                goto err_i1;
                        }
                }
                retcode = func(dev, kdata, file_priv);
 
-               if (cmd & IOC_OUT) {
+               if ((retcode == 0) && (cmd & IOC_OUT)) {
                        if (copy_to_user((void __user *)arg, kdata,
                                         _IOC_SIZE(cmd)) != 0)
-                               retcode = -EACCES;
+                               retcode = -EFAULT;
                }
        }