[PATCH] hpet: fix HPET_INFO calls from kernel space

Fix a wrong memory access in hpet_ioctl_common().  It was not possible to use
the HPET_INFO ioctl from kernel space because it always called copy_to_user().

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Cc: Bob Picco <bob.picco@hp.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
Clemens Ladisch 2005-10-30 15:03:37 -08:00 committed by Linus Torvalds
parent 7811fb8f40
commit 8e8505be9c

View File

@ -500,8 +500,12 @@ hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg, int kernel)
readq(&timer->hpet_config) & Tn_PER_INT_CAP_MASK; readq(&timer->hpet_config) & Tn_PER_INT_CAP_MASK;
info.hi_hpet = devp->hd_hpets->hp_which; info.hi_hpet = devp->hd_hpets->hp_which;
info.hi_timer = devp - devp->hd_hpets->hp_dev; info.hi_timer = devp - devp->hd_hpets->hp_dev;
if (copy_to_user((void __user *)arg, &info, sizeof(info))) if (kernel)
err = -EFAULT; memcpy((void *)arg, &info, sizeof(info));
else
if (copy_to_user((void __user *)arg, &info,
sizeof(info)))
err = -EFAULT;
break; break;
} }
case HPET_EPI: case HPET_EPI: