提交 f3537ea7 编写于 作者: A Atsushi Nemoto 提交者: Linus Torvalds

[PATCH] genrtc: fix read on 64-bit platforms

Fix genrtc's read() routine for 64-bit platforms.  Current gen_rtc_read()
stores 64bit integer and returns 8 even if an user tried to read a 32bit
integer.
Signed-off-by: NAtsushi Nemoto <anemo@mba.ocn.ne.jp>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 3418ff76
...@@ -200,13 +200,13 @@ static ssize_t gen_rtc_read(struct file *file, char __user *buf, ...@@ -200,13 +200,13 @@ static ssize_t gen_rtc_read(struct file *file, char __user *buf,
/* first test allows optimizer to nuke this case for 32-bit machines */ /* first test allows optimizer to nuke this case for 32-bit machines */
if (sizeof (int) != sizeof (long) && count == sizeof (unsigned int)) { if (sizeof (int) != sizeof (long) && count == sizeof (unsigned int)) {
unsigned int uidata = data; unsigned int uidata = data;
retval = put_user(uidata, (unsigned long __user *)buf); retval = put_user(uidata, (unsigned int __user *)buf) ?:
sizeof(unsigned int);
} }
else { else {
retval = put_user(data, (unsigned long __user *)buf); retval = put_user(data, (unsigned long __user *)buf) ?:
sizeof(unsigned long);
} }
if (!retval)
retval = sizeof(unsigned long);
out: out:
current->state = TASK_RUNNING; current->state = TASK_RUNNING;
remove_wait_queue(&gen_rtc_wait, &wait); remove_wait_queue(&gen_rtc_wait, &wait);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册