From: Ian Campbell <ijc@hellion.org.uk>
To: Dmitry Torokhov <dtor@mail.ru>, Vojtech Pavlik <vojtech@suse.cz>
Cc: linux-kernel@vger.kernel.org
Subject: Checking keycodesize when adjusting keymaps breaks my IR remote
Date: Tue, 30 Aug 2005 09:38:26 +0100 [thread overview]
Message-ID: <1125391106.6565.8.camel@azathoth.hellion.org.uk> (raw)
[-- Attachment #1: Type: text/plain, Size: 2051 bytes --]
Hi Gents,
This patch:
http://marc.theaimsgroup.com/?l=linux-kernel&m=112227485202277&w=2
seems to break the remote control on my PVR-350 using ir-kbd-i2c.c.
The check "if (v >> (dev->keycodesize * 8))" in
evdev_ioctl:EVIOCSKEYCODE prevents me from loading the keymap. This is
because dev->keycodesize=4 so the size of the shift is 32 and the size
of v is also 32. For example it is called with v == 82 which gives v >>
(dev->keycodesize * 8) == 82 >> 32 which comes out as 82!
I think when the size of the shift is the size of the type, the result
of the shift is either undefined or triggers a bug in gcc (most likely
the former IMHO, but I don't have a reference to check).
There are no warnings when compiling the kernel because the shift size
is unknown at compile time, but if I explicitly write "v >> 32" then I
get:
warning: right shift count >= width of type
I think the solution (workaround?) is to only perform this check if
keycodesize is less than sizeof(v). I'm unsure about adding a separate
check for keycodesize > sizeof(v). Casting v to a type > 32 bits also
does the trick if you prefer.
I wonder if the same applies in drivers/char/keyboard.c?
Signed-off-by: Ian Campbell <ijc@hellion.org.uk>
Index: 2.6/drivers/input/evdev.c
===================================================================
--- 2.6.orig/drivers/input/evdev.c 2005-08-29 10:40:22.000000000 +0100
+++ 2.6/drivers/input/evdev.c 2005-08-30 09:23:31.000000000 +0100
@@ -320,7 +320,7 @@
if (t < 0 || t >= dev->keycodemax || !dev->keycodesize) return -EINVAL;
if (get_user(v, ip + 1)) return -EFAULT;
if (v < 0 || v > KEY_MAX) return -EINVAL;
- if (v >> (dev->keycodesize * 8)) return -EINVAL;
+ if (dev->keycodesize < sizeof(v) && v >> (dev->keycodesize * 8)) return -EINVAL;
u = SET_INPUT_KEYCODE(dev, t, v);
clear_bit(u, dev->keybit);
set_bit(v, dev->keybit);
--
Ian Campbell
The biggest difference between time and space is that you can't reuse time.
-- Merrick Furst
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
reply other threads:[~2005-08-30 8:38 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=1125391106.6565.8.camel@azathoth.hellion.org.uk \
--to=ijc@hellion.org.uk \
--cc=dtor@mail.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=vojtech@suse.cz \
/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
all inboxes | Powered by JetHome®