* [PATCH] genrtc: fix read on 64-bit platforms
@ 2006-04-28 16:38 Atsushi Nemoto
2006-04-29 6:34 ` Andrew Morton
0 siblings, 1 reply; 3+ messages in thread
From: Atsushi Nemoto @ 2006-04-28 16:38 UTC (permalink / raw)
To: linux-kernel; +Cc: akpm
Fix genrtc's read() routine for 64-bit platforms.
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
index d3a2bc3..588fca5 100644
--- a/drivers/char/genrtc.c
+++ b/drivers/char/genrtc.c
@@ -200,13 +200,13 @@ static ssize_t gen_rtc_read(struct file
/* first test allows optimizer to nuke this case for 32-bit machines */
if (sizeof (int) != sizeof (long) && count == sizeof (unsigned int)) {
unsigned int uidata = data;
- retval = put_user(uidata, (unsigned long __user *)buf);
+ retval = put_user(uidata, (unsigned int __user *)buf) ?:
+ sizeof(unsigned int);
}
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:
current->state = TASK_RUNNING;
remove_wait_queue(&gen_rtc_wait, &wait);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] genrtc: fix read on 64-bit platforms
2006-04-28 16:38 [PATCH] genrtc: fix read on 64-bit platforms Atsushi Nemoto
@ 2006-04-29 6:34 ` Andrew Morton
2006-04-29 14:11 ` Atsushi Nemoto
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2006-04-29 6:34 UTC (permalink / raw)
To: Atsushi Nemoto; +Cc: linux-kernel
Atsushi Nemoto <anemo@mba.ocn.ne.jp> wrote:
>
> Fix genrtc's read() routine for 64-bit platforms.
>
When fixing something, please provide a description of what the problem was
and also a description of how the patch fixes it (unless it's obvious, of
course).
Thanks.
>
> diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
> index d3a2bc3..588fca5 100644
> --- a/drivers/char/genrtc.c
> +++ b/drivers/char/genrtc.c
> @@ -200,13 +200,13 @@ static ssize_t gen_rtc_read(struct file
> /* first test allows optimizer to nuke this case for 32-bit machines */
> if (sizeof (int) != sizeof (long) && count == sizeof (unsigned int)) {
> unsigned int uidata = data;
> - retval = put_user(uidata, (unsigned long __user *)buf);
> + retval = put_user(uidata, (unsigned int __user *)buf) ?:
> + sizeof(unsigned int);
> }
> 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:
> current->state = TASK_RUNNING;
> remove_wait_queue(&gen_rtc_wait, &wait);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] genrtc: fix read on 64-bit platforms
2006-04-29 6:34 ` Andrew Morton
@ 2006-04-29 14:11 ` Atsushi Nemoto
0 siblings, 0 replies; 3+ messages in thread
From: Atsushi Nemoto @ 2006-04-29 14:11 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, alessandro.zummo
On Fri, 28 Apr 2006 23:34:21 -0700, Andrew Morton <akpm@osdl.org> wrote:
> > Fix genrtc's read() routine for 64-bit platforms.
>
> When fixing something, please provide a description of what the problem was
> and also a description of how the patch fixes it (unless it's obvious, of
> course).
Thanks. Here is a same patch with an updated description.
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>
diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
index d3a2bc3..588fca5 100644
--- a/drivers/char/genrtc.c
+++ b/drivers/char/genrtc.c
@@ -200,13 +200,13 @@ static ssize_t gen_rtc_read(struct file
/* first test allows optimizer to nuke this case for 32-bit machines */
if (sizeof (int) != sizeof (long) && count == sizeof (unsigned int)) {
unsigned int uidata = data;
- retval = put_user(uidata, (unsigned long __user *)buf);
+ retval = put_user(uidata, (unsigned int __user *)buf) ?:
+ sizeof(unsigned int);
}
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:
current->state = TASK_RUNNING;
remove_wait_queue(&gen_rtc_wait, &wait);
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-04-29 14:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-28 16:38 [PATCH] genrtc: fix read on 64-bit platforms Atsushi Nemoto
2006-04-29 6:34 ` Andrew Morton
2006-04-29 14:11 ` Atsushi Nemoto
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®