linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] HID: uHID: fix excepted report type
@ 2014-10-01 15:59 Benjamin Tissoires
  2014-10-01 16:36 ` David Herrmann
  0 siblings, 1 reply; 3+ messages in thread
From: Benjamin Tissoires @ 2014-10-01 15:59 UTC (permalink / raw)
  To: David Herrmann, Jiri Kosina; +Cc: linux-input, linux-kernel

When uhid_get_report() or uhid_set_report() are called, they emit on the
char device a UHID_GET_REPORT or UHID_SET_REPORT message. Then, the
protocol says that the user space asnwers with UHID_GET_REPORT_REPLY
or UHID_SET_REPORT_REPLY.

Unfortunatelly, the current code waits for an event of type UHID_GET_REPORT
or UHID_SET_REPORT instead of the reply one.
Add 1 to UHID_GET_REPORT or UHID_SET_REPORT to actually wait for the
reply, and validate the reply.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---

Hi David,

while playing with a Bluetooth LE mouse, I noticed that uhid did not validate
properly the get_report feature. With this patch and some work on bluez, this
part now works almost (at least I manage to get reports from the device, there
is still a 0x0b header I can not rely to anything, so there will be some work
to do in Bordeaux :) )

Cheers,
Benjamin

 drivers/hid/uhid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
index f6ec5ea..e094c57 100644
--- a/drivers/hid/uhid.c
+++ b/drivers/hid/uhid.c
@@ -154,7 +154,7 @@ static int __uhid_report_queue_and_wait(struct uhid_device *uhid,
 
 	spin_lock_irqsave(&uhid->qlock, flags);
 	*report_id = ++uhid->report_id;
-	uhid->report_type = ev->type;
+	uhid->report_type = ev->type + 1;
 	uhid->report_running = true;
 	uhid_queue(uhid, ev);
 	spin_unlock_irqrestore(&uhid->qlock, flags);
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] HID: uHID: fix excepted report type
  2014-10-01 15:59 [PATCH] HID: uHID: fix excepted report type Benjamin Tissoires
@ 2014-10-01 16:36 ` David Herrmann
  2014-10-01 19:01   ` Jiri Kosina
  0 siblings, 1 reply; 3+ messages in thread
From: David Herrmann @ 2014-10-01 16:36 UTC (permalink / raw)
  To: Benjamin Tissoires
  Cc: David Herrmann, Jiri Kosina, open list:HID CORE LAYER,
	linux-kernel

Hi

On Wed, Oct 1, 2014 at 5:59 PM, Benjamin Tissoires
<benjamin.tissoires@redhat.com> wrote:
> When uhid_get_report() or uhid_set_report() are called, they emit on the
> char device a UHID_GET_REPORT or UHID_SET_REPORT message. Then, the
> protocol says that the user space asnwers with UHID_GET_REPORT_REPLY
> or UHID_SET_REPORT_REPLY.
>
> Unfortunatelly, the current code waits for an event of type UHID_GET_REPORT
> or UHID_SET_REPORT instead of the reply one.
> Add 1 to UHID_GET_REPORT or UHID_SET_REPORT to actually wait for the
> reply, and validate the reply.
>
> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
> ---
>
> Hi David,
>
> while playing with a Bluetooth LE mouse, I noticed that uhid did not validate
> properly the get_report feature. With this patch and some work on bluez, this
> part now works almost (at least I manage to get reports from the device, there
> is still a 0x0b header I can not rely to anything, so there will be some work
> to do in Bordeaux :) )
>
> Cheers,
> Benjamin
>
>  drivers/hid/uhid.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
> index f6ec5ea..e094c57 100644
> --- a/drivers/hid/uhid.c
> +++ b/drivers/hid/uhid.c
> @@ -154,7 +154,7 @@ static int __uhid_report_queue_and_wait(struct uhid_device *uhid,
>
>         spin_lock_irqsave(&uhid->qlock, flags);
>         *report_id = ++uhid->report_id;
> -       uhid->report_type = ev->type;
> +       uhid->report_type = ev->type + 1;

Nice catch. We always need the *_REPLY type as response:

Reviewed-by: David Herrmann <dh.herrmann@gmail.com>

Thanks for trying to fix this! I will try to get my Arc-Surface
working until Bordeaux. We should be able to get all that stuff
figured out together then. And it will still be in time for 3.18-fixes
then.

Thanks
David

>         uhid->report_running = true;
>         uhid_queue(uhid, ev);
>         spin_unlock_irqrestore(&uhid->qlock, flags);
> --
> 1.9.3
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] HID: uHID: fix excepted report type
  2014-10-01 16:36 ` David Herrmann
@ 2014-10-01 19:01   ` Jiri Kosina
  0 siblings, 0 replies; 3+ messages in thread
From: Jiri Kosina @ 2014-10-01 19:01 UTC (permalink / raw)
  To: David Herrmann
  Cc: Benjamin Tissoires, David Herrmann, open list:HID CORE LAYER,
	linux-kernel

On Wed, 1 Oct 2014, David Herrmann wrote:

> > diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
> > index f6ec5ea..e094c57 100644
> > --- a/drivers/hid/uhid.c
> > +++ b/drivers/hid/uhid.c
> > @@ -154,7 +154,7 @@ static int __uhid_report_queue_and_wait(struct uhid_device *uhid,
> >
> >         spin_lock_irqsave(&uhid->qlock, flags);
> >         *report_id = ++uhid->report_id;
> > -       uhid->report_type = ev->type;
> > +       uhid->report_type = ev->type + 1;
> 
> Nice catch. We always need the *_REPLY type as response:
> 
> Reviewed-by: David Herrmann <dh.herrmann@gmail.com>

Applied, thanks.

-- 
Jiri Kosina
SUSE Labs

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-10-01 19:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-01 15:59 [PATCH] HID: uHID: fix excepted report type Benjamin Tissoires
2014-10-01 16:36 ` David Herrmann
2014-10-01 19:01   ` Jiri Kosina

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).