Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Atsushi Nemoto and committed by
Linus Torvalds
f3537ea7 3418ff76

+4 -4
+4 -4
drivers/char/genrtc.c
··· 200 200 /* first test allows optimizer to nuke this case for 32-bit machines */ 201 201 if (sizeof (int) != sizeof (long) && count == sizeof (unsigned int)) { 202 202 unsigned int uidata = data; 203 - retval = put_user(uidata, (unsigned long __user *)buf); 203 + retval = put_user(uidata, (unsigned int __user *)buf) ?: 204 + sizeof(unsigned int); 204 205 } 205 206 else { 206 - retval = put_user(data, (unsigned long __user *)buf); 207 + retval = put_user(data, (unsigned long __user *)buf) ?: 208 + sizeof(unsigned long); 207 209 } 208 - if (!retval) 209 - retval = sizeof(unsigned long); 210 210 out: 211 211 current->state = TASK_RUNNING; 212 212 remove_wait_queue(&gen_rtc_wait, &wait);