From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?utf-8?Q?Denilson_Figueiredo_de_S=C3=A1?= Subject: Re: Linux USB HID should ignore values outside Logical Minimum/Maximum range Date: Fri, 28 Oct 2011 18:40:20 -0200 Message-ID: References: <1319476183.3210.12.camel@lovely> <20111024203204.GA31721@core.coreip.homeip.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed delsp=yes Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org To: Dmitry Torokhov , Jiri Kosina Cc: Christoph Fritz , linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-usb@vger.kernel.org List-Id: linux-input@vger.kernel.org On Fri, 28 Oct 2011 14:23:17 -0200, Jiri Kosina wrote= : > On the other hand I feel like just dropping the report on the floor =20 > should be the proper thing to do. I'd say not the entire report, but just the invalid fields. The HID specification (HID1_11.pdf) talks about "Null Values" at the =20 section 5.10 (page 20). [quote] HID class devices support the ability to ignore selected fields in a =20 report at run- time. This is accomplished by declaring bit field in a report that is =20 capable of containing a range of values larger than those actually generated by th= e =20 control. If the host or the device receives an out-of-range value then the current = =20 value for the respective control will not be modified. [/quote] (sidenote: Why didn't I mention this spec earlier? Because I knew I hav= e =20 read that information somewhere, but didn't find it again until today.) > Christoph, how about the (untested at my side yet) patch below? It'd = be > nice if you could test with the device you are seeing the problem wit= h =20 > and let me know. I can't test it *right now*, but I can probably test it in a week or tw= o. > + /* Ignore absolute values that are out of bounds */ > + if ((usage->type =3D=3D EV_ABS && (value < field->logical_minimum |= | > + value > field->logical_maximum))) { Given what the HID spec says (as I quoted above), I'd change this =20 condition to just: > + if (value < field->logical_minimum || > + value > field->logical_maximum) { On the other hand, HID spec also defines the "Null" bit of Input fields= at =20 page 31. This Null bit seems redundant for me, as (in my understanding)= =20 any value outside the range is automatically a null value. We wouldn't = =20 need a Null bit for that. Anyway, another solution is to change that condition to something like = =20 this: > + if ( THIS_INPUT_FIELD_HAS_NULL_BIT_SET && > + (value < field->logical_minimum || > + value > field->logical_maximum)) { What do you think? --=20 Denilson Figueiredo de S=C3=A1 Rio de Janeiro - Brasil