Skip to contentSkip to conversation

HID: roccat: Fixing race condition on initialization

PATCH In review Stefan Achatz 2 participants 3 messages Aug 28, 2010

Subsystems (2)
lore
Share & tools
lore

Stefan Achatz

author maintainer
#0 lore raw

PATCH 1/1 HID: roccat: Fixing race condition on initialization

Fixed raced condition where event occurs before drvdata is set.

---
 drivers/hid/hid-roccat-kone.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/hid/hid-roccat-kone.c +4 -0
index f776957..cfeab56 100644
@@ -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;
Signature · 1 line
1.7.2.2
#1 lore raw
Quoted 12 lines · Stefan Achatz

Fixed raced condition where event occurs before drvdata is set.

---
 drivers/hid/hid-roccat-kone.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/hid/hid-roccat-kone.c +0 -0
index f776957..cfeab56 100644

drivers/hid/hid-roccat-kone.c static int kone_raw_event(struct hid_device *hdev, struct hid_report *report, · line 971

Quoted 6 lines
drivers/hid/hid-roccat-kone.c +3 -0
@@ -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,

Signature · 1 line
js
author maintainer
#2 lore raw

Am Samstag, den 28.08.2010, 20:18 +0200 schrieb Jiri Slaby:

Quoted 24 lines · Stefan Achatz
Quoted 12 lines

Fixed raced condition where event occurs before drvdata is set.

---
 drivers/hid/hid-roccat-kone.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/hid/hid-roccat-kone.c +0 -0
index f776957..cfeab56 100644

drivers/hid/hid-roccat-kone.c static int kone_raw_event(struct hid_device *hdev, struct hid_report *report, · line 971

Quoted 6 lines
drivers/hid/hid-roccat-kone.c +3 -0
@@ -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.

Quoted 3 lines

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.