[kernel/f18] Add patch from Benjamin Tissoires to fix race in HID magicmouse (rhbz 908604)

Josh Boyer jwboyer at fedoraproject.org
Mon Apr 8 13:26:56 UTC 2013


commit 97aee9cc43be1a577160125c70788580fe44ac60
Author: Josh Boyer <jwboyer at redhat.com>
Date:   Mon Apr 8 09:25:52 2013 -0400

    Add patch from Benjamin Tissoires to fix race in HID magicmouse (rhbz 908604)

 ...fix-race-between-input_register-and-probe.patch |   83 ++++++++++++++++++++
 kernel.spec                                        |   11 +++-
 2 files changed, 93 insertions(+), 1 deletions(-)
---
diff --git a/HID-magicmouse-fix-race-between-input_register-and-probe.patch b/HID-magicmouse-fix-race-between-input_register-and-probe.patch
new file mode 100644
index 0000000..87f0ccb
--- /dev/null
+++ b/HID-magicmouse-fix-race-between-input_register-and-probe.patch
@@ -0,0 +1,83 @@
+From f1a9a149abc86903e81dd1b2e720f3f89874384b Mon Sep 17 00:00:00 2001
+From: Benjamin Tissoires <benjamin.tissoires at redhat.com>
+Date: Tue, 2 Apr 2013 11:11:52 +0200
+Subject: HID: magicmouse: fix race between input_register() and probe()
+
+From: Benjamin Tissoires <benjamin.tissoires at redhat.com>
+
+commit f1a9a149abc86903e81dd1b2e720f3f89874384b upstream.
+
+Since kernel 3.7, it appears that the input registration occured before
+the end of magicmouse_setup_input(). This is shown by receiving a lot of
+"EV_SYN SYN_REPORT 1" instead of normal "EV_SYN SYN_REPORT 0".
+This value means that the output buffer is full, and the user space
+is loosing events.
+
+Using .input_configured guarantees that the race is not occuring, and that
+the call of "input_set_events_per_packet(input, 60)" is taken into account
+by input_register().
+
+Fixes:
+https://bugzilla.redhat.com/show_bug.cgi?id=908604
+
+Reported-and-Tested-By: Clarke Wixon <cwixon at usa.net>
+Signed-off-by: Benjamin Tissoires <benjamin.tissoires at redhat.com>
+Signed-off-by: Jiri Kosina <jkosina at suse.cz>
+Signed-off-by: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
+
+---
+ drivers/hid/hid-magicmouse.c |   29 ++++++++++++++++++++---------
+ 1 file changed, 20 insertions(+), 9 deletions(-)
+
+--- a/drivers/hid/hid-magicmouse.c
++++ b/drivers/hid/hid-magicmouse.c
+@@ -462,6 +462,21 @@ static int magicmouse_input_mapping(stru
+ 	return 0;
+ }
+ 
++static void magicmouse_input_configured(struct hid_device *hdev,
++		struct hid_input *hi)
++
++{
++	struct magicmouse_sc *msc = hid_get_drvdata(hdev);
++
++	int ret = magicmouse_setup_input(msc->input, hdev);
++	if (ret) {
++		hid_err(hdev, "magicmouse setup input failed (%d)\n", ret);
++		/* clean msc->input to notify probe() of the failure */
++		msc->input = NULL;
++	}
++}
++
++
+ static int magicmouse_probe(struct hid_device *hdev,
+ 	const struct hid_device_id *id)
+ {
+@@ -493,15 +508,10 @@ static int magicmouse_probe(struct hid_d
+ 		goto err_free;
+ 	}
+ 
+-	/* We do this after hid-input is done parsing reports so that
+-	 * hid-input uses the most natural button and axis IDs.
+-	 */
+-	if (msc->input) {
+-		ret = magicmouse_setup_input(msc->input, hdev);
+-		if (ret) {
+-			hid_err(hdev, "magicmouse setup input failed (%d)\n", ret);
+-			goto err_stop_hw;
+-		}
++	if (!msc->input) {
++		hid_err(hdev, "magicmouse input not registered\n");
++		ret = -ENOMEM;
++		goto err_stop_hw;
+ 	}
+ 
+ 	if (id->product == USB_DEVICE_ID_APPLE_MAGICMOUSE)
+@@ -568,6 +578,7 @@ static struct hid_driver magicmouse_driv
+ 	.remove = magicmouse_remove,
+ 	.raw_event = magicmouse_raw_event,
+ 	.input_mapping = magicmouse_input_mapping,
++	.input_configured = magicmouse_input_configured,
+ };
+ 
+ static int __init magicmouse_init(void)
diff --git a/kernel.spec b/kernel.spec
index e68c161..b6bd130 100644
--- a/kernel.spec
+++ b/kernel.spec
@@ -62,7 +62,7 @@ Summary: The Linux kernel
 # For non-released -rc kernels, this will be appended after the rcX and
 # gitX tags, so a 3 here would become part of release "0.rcX.gitX.3"
 #
-%global baserelease 201
+%global baserelease 202
 %global fedora_build %{baserelease}
 
 # base_sublevel is the kernel version we're starting with and patching
@@ -792,6 +792,9 @@ Patch25007: fix-child-thread-introspection.patch
 #rhbz 844750
 Patch25008: 0001-bluetooth-Add-support-for-atheros-04ca-3004-device-t.patch
 
+#rhbz 908604
+Patch25009: HID-magicmouse-fix-race-between-input_register-and-probe.patch
+
 # END OF PATCH DEFINITIONS
 
 %endif
@@ -1533,6 +1536,9 @@ ApplyPatch fix-child-thread-introspection.patch
 
 ApplyPatch 0001-bluetooth-Add-support-for-atheros-04ca-3004-device-t.patch
 
+#rhbz 908604
+ApplyPatch HID-magicmouse-fix-race-between-input_register-and-probe.patch
+
 # END OF PATCH APPLICATIONS
 
 %endif
@@ -2390,6 +2396,9 @@ fi
 #                 ||----w |
 #                 ||     ||
 %changelog
+* Mon Apr 08 2013 Josh Boyer <jwboyer at redhat.com>
+- Add patch from Benjamin Tissoires to fix race in HID magicmouse (rhbz 908604)
+
 * Fri Apr 05 2013 Justin M. Forbes <jforbes at redhat.com>
 - Linux v3.8.6
 


More information about the scm-commits mailing list