linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] HID: roccat: Fixing race condition on initialization
@ 2010-08-28 12:57 Stefan Achatz
  2010-08-28 18:18 ` Jiri Slaby
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Achatz @ 2010-08-28 12:57 UTC (permalink / raw)
  To: Jiri Kosina, Stefan Achatz, Stephen Rothwell, Tejun Heo,
	linux-input

Fixed raced condition where event occurs before drvdata is set.

Signed-off-by: Stefan Achatz <erazor_de@users.sourceforge.net>
---
 drivers/hid/hid-roccat-kone.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/hid/hid-roccat-kone.c b/drivers/hid/hid-roccat-kone.c
index f776957..cfeab56 100644
--- a/drivers/hid/hid-roccat-kone.c
+++ b/drivers/hid/hid-roccat-kone.c
@@ -966,6 +966,10 @@ static int kone_raw_event(struct hid_device *hdev, struct hid_report *report,
 	struct kone_device *kone = hid_get_drvdata(hdev);
 	struct kone_mouse_event *event = (struct kone_mouse_event *)data;
 
+	/* possible race condition on initialization */
+	if (!kone)
+		return 0;
+
 	/* keyboard events are always processed by default handler */
 	if (size != sizeof(struct kone_mouse_event))
 		return 0;
-- 
1.7.2.2




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

* Re: [PATCH] HID: roccat: Fixing race condition on initialization
  2010-08-28 12:57 [PATCH] HID: roccat: Fixing race condition on initialization Stefan Achatz
@ 2010-08-28 18:18 ` Jiri Slaby
  2010-08-28 22:11   ` Stefan Achatz
  0 siblings, 1 reply; 3+ messages in thread
From: Jiri Slaby @ 2010-08-28 18:18 UTC (permalink / raw)
  To: erazor_de
  Cc: Jiri Kosina, Stephen Rothwell, Tejun Heo, linux-input,
	linux-kernel

On 08/28/2010 02:57 PM, Stefan Achatz wrote:
> Fixed raced condition where event occurs before drvdata is set.
> 
> Signed-off-by: Stefan Achatz <erazor_de@users.sourceforge.net>
> ---
>  drivers/hid/hid-roccat-kone.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/hid/hid-roccat-kone.c b/drivers/hid/hid-roccat-kone.c
> index f776957..cfeab56 100644
> --- a/drivers/hid/hid-roccat-kone.c
> +++ b/drivers/hid/hid-roccat-kone.c
> @@ -966,6 +966,10 @@ static int kone_raw_event(struct hid_device *hdev, struct hid_report *report,
>  	struct kone_device *kone = hid_get_drvdata(hdev);
>  	struct kone_mouse_event *event = (struct kone_mouse_event *)data;
>  
> +	/* possible race condition on initialization */
> +	if (!kone)
> +		return 0;

This kind of "protection" caused much headache in the tty layer in the
past. If there is such a problem, please fix the initialization code
instead.

What sort of problems you are seeing?

thanks,
-- 
js

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

* Re: [PATCH] HID: roccat: Fixing race condition on initialization
  2010-08-28 18:18 ` Jiri Slaby
@ 2010-08-28 22:11   ` Stefan Achatz
  0 siblings, 0 replies; 3+ messages in thread
From: Stefan Achatz @ 2010-08-28 22:11 UTC (permalink / raw)
  To: Jiri Slaby
  Cc: Jiri Kosina, Stephen Rothwell, linux-input, Tejun Heo,
	linux-kernel

Am Samstag, den 28.08.2010, 20:18 +0200 schrieb Jiri Slaby:
> On 08/28/2010 02:57 PM, Stefan Achatz wrote:
> > Fixed raced condition where event occurs before drvdata is set.
> > 
> > Signed-off-by: Stefan Achatz <erazor_de@users.sourceforge.net>
> > ---
> >  drivers/hid/hid-roccat-kone.c |    4 ++++
> >  1 files changed, 4 insertions(+), 0 deletions(-)
> > 
> > diff --git a/drivers/hid/hid-roccat-kone.c b/drivers/hid/hid-roccat-kone.c
> > index f776957..cfeab56 100644
> > --- a/drivers/hid/hid-roccat-kone.c
> > +++ b/drivers/hid/hid-roccat-kone.c
> > @@ -966,6 +966,10 @@ static int kone_raw_event(struct hid_device *hdev, struct hid_report *report,
> >  	struct kone_device *kone = hid_get_drvdata(hdev);
> >  	struct kone_mouse_event *event = (struct kone_mouse_event *)data;
> >  
> > +	/* possible race condition on initialization */
> > +	if (!kone)
> > +		return 0;
> 
> This kind of "protection" caused much headache in the tty layer in the
> past. If there is such a problem, please fix the initialization code
> instead.
> 
> What sort of problems you are seeing?
> 
> thanks,

After investigating and now fully understanding the issue I want to draw
back this patch.
The issue was no race condition in the first place, but an erroneous
code I wrote for another mouse. This is a injudicious crossport of a
half baked fix for code that didn't suffer from the problem because the
next 3 lines already do the right thing for this case.
Sorry.


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

end of thread, other threads:[~2010-08-28 22:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-28 12:57 [PATCH] HID: roccat: Fixing race condition on initialization Stefan Achatz
2010-08-28 18:18 ` Jiri Slaby
2010-08-28 22:11   ` Stefan Achatz

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).