Skip to content

Commit

Permalink
drm: fixup some of the ioctl function exit paths
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Airlie <airlied@linux.ie>
  • Loading branch information
Dave Airlie committed Feb 7, 2008
1 parent 19a8f59 commit 9d5b3ff
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions drivers/char/drm/drm_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down

0 comments on commit 9d5b3ff

Please sign in to comment.