From: Al Viro <viro@ftp.linux.org.uk>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Greg Kroah-Hartman <gregkh@suse.de>, linux-kernel@vger.kernel.org
Subject: [PATCH] idmouse cleanup and overflow fix
Date: Sat, 29 Oct 2005 11:56:13 +0100 [thread overview]
Message-ID: <20051029105613.GG7992@ftp.linux.org.uk> (raw)
switched to simple_read_from_buffer(), killed broken use of min().
Incidentally, that use of min() had been fixed once, only to be reintroduced
in
[PATCH] USB: upgrade of the idmouse driver
[snip]
- if (count > IMGSIZE - *ppos)
- count = IMGSIZE - *ppos;
+ count = min ((loff_t)count, IMGSIZE - (*ppos));
Note the lovely use of cast to shut the warning about misuse of min() up...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
----
diff -urN RC14-base/drivers/usb/misc/idmouse.c current/drivers/usb/misc/idmouse.c
--- RC14-base/drivers/usb/misc/idmouse.c 2005-10-29 02:47:52.000000000 -0400
+++ current/drivers/usb/misc/idmouse.c 2005-10-29 06:07:49.000000000 -0400
@@ -319,20 +319,8 @@
return -ENODEV;
}
- if (*ppos >= IMGSIZE) {
- up (&dev->sem);
- return 0;
- }
-
- count = min ((loff_t)count, IMGSIZE - (*ppos));
-
- if (copy_to_user (buffer, dev->bulk_in_buffer + *ppos, count)) {
- result = -EFAULT;
- } else {
- result = count;
- *ppos += count;
- }
-
+ result = simple_read_from_buffer(buffer, count, ppos,
+ dev->bulk_in_buffer, IMGSIZE);
/* unlock the device */
up(&dev->sem);
return result;
reply other threads:[~2005-10-29 10:56 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20051029105613.GG7992@ftp.linux.org.uk \
--to=viro@ftp.linux.org.uk \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox