Re: linux-next: Tree for July 30

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linus Torvalds
Date: Thursday, July 31, 2008 - 1:28 pm

On Thu, 31 Jul 2008, Linus Torvalds wrote:

Or just say that "if the buffer is really much too big, maybe they meant 
bits"?

IOW, something like this?

(And no, I'm not seriously proposing _this_ patch, but you get the idea)

		Linus
---
 drivers/input/evdev.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 2d65411..e45451d 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -734,7 +734,7 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
 		if (_IOC_DIR(cmd) == _IOC_READ) {
 
 			if ((_IOC_NR(cmd) & ~EV_MAX) == _IOC_NR(EVIOCGBIT(0, 0))) {
-
+				unsigned int size = _IOC_SIZE(cmd);
 				unsigned long *bits;
 				int len;
 
@@ -751,7 +751,12 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
 				case EV_SW:  bits = dev->swbit;  len = SW_MAX;  break;
 				default: return -EINVAL;
 				}
-				return bits_to_user(bits, len, _IOC_SIZE(cmd), p, compat_mode);
+
+				/* Some people get confused about size in bits vs bytes */
+				if (size >= len/8)
+					size = size/8;
+
+				return bits_to_user(bits, len, size, p, compat_mode);
 			}
 
 			if (_IOC_NR(cmd) == _IOC_NR(EVIOCGKEY(0)))
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
linux-next: Tree for July 30, Stephen Rothwell, (Wed Jul 30, 12:06 am)
Re: linux-next: Tree for July 30, Takashi Iwai, (Wed Jul 30, 7:47 am)
Re: linux-next: Tree for July 30, Andrew Morton, (Wed Jul 30, 11:10 pm)
Re: linux-next: Tree for July 30, Dmitry Torokhov, (Thu Jul 31, 7:07 am)
Re: linux-next: Tree for July 30, Bartlomiej Zolnierki ..., (Thu Jul 31, 8:36 am)
Re: linux-next: Tree for July 30, Dmitry Torokhov, (Thu Jul 31, 8:56 am)
Re: linux-next: Tree for July 30, Andrew Morton, (Thu Jul 31, 10:44 am)
Re: linux-next: Tree for July 30, Dmitry Torokhov, (Thu Jul 31, 11:17 am)
Re: linux-next: Tree for July 30, Andrew Morton, (Thu Jul 31, 11:26 am)
Re: linux-next: Tree for July 30, Dmitry Torokhov, (Thu Jul 31, 11:34 am)
Re: linux-next: Tree for July 30, Rafael J. Wysocki, (Thu Jul 31, 11:48 am)
Re: linux-next: Tree for July 30, Dmitry Torokhov, (Thu Jul 31, 11:54 am)
Re: linux-next: Tree for July 30, Andrew Morton, (Thu Jul 31, 11:55 am)
Re: linux-next: Tree for July 30, Dmitry Torokhov, (Thu Jul 31, 12:03 pm)
Re: linux-next: Tree for July 30, Linus Torvalds, (Thu Jul 31, 12:10 pm)
Re: linux-next: Tree for July 30, Andrew Morton, (Thu Jul 31, 12:13 pm)
Re: linux-next: Tree for July 30, Hugh Dickins, (Thu Jul 31, 12:20 pm)
Re: linux-next: Tree for July 30, Dmitry Torokhov, (Thu Jul 31, 12:24 pm)
Re: linux-next: Tree for July 30, Dmitry Torokhov, (Thu Jul 31, 12:42 pm)
Re: linux-next: Tree for July 30, Linus Torvalds, (Thu Jul 31, 12:44 pm)
Re: linux-next: Tree for July 30, Rafael J. Wysocki, (Thu Jul 31, 12:57 pm)
Re: linux-next: Tree for July 30, Dmitry Torokhov, (Thu Jul 31, 1:05 pm)
Re: linux-next: Tree for July 30, Andrew Morton, (Thu Jul 31, 1:10 pm)
Re: linux-next: Tree for July 30, Linus Torvalds, (Thu Jul 31, 1:16 pm)
Re: linux-next: Tree for July 30, Linus Torvalds, (Thu Jul 31, 1:28 pm)
Re: linux-next: Tree for July 30, Dmitry Torokhov, (Thu Jul 31, 1:28 pm)
Re: linux-next: Tree for July 30, Dmitry Torokhov, (Thu Jul 31, 1:39 pm)
Re: linux-next: Tree for July 30, Linus Torvalds, (Fri Aug 1, 12:12 pm)
Re: linux-next: Tree for July 30, Dmitry Torokhov, (Fri Aug 1, 12:23 pm)
Re: linux-next: Tree for July 30, Linus Torvalds, (Fri Aug 1, 12:26 pm)
Re: linux-next: Tree for July 30, Stephen Rothwell, (Sun Aug 3, 10:47 pm)
Re: linux-next: Tree for July 30, Dmitry Torokhov, (Thu Aug 7, 11:11 am)
Re: linux-next: Tree for July 30, Andrew Morton, (Thu Aug 7, 11:50 am)
Re: linux-next: Tree for July 30, Rafael J. Wysocki, (Thu Aug 7, 11:55 am)
Re: linux-next: Tree for July 30, Dmitry Torokhov, (Thu Aug 7, 12:06 pm)