HID: sony: Fix work queue issues.
PATCH 1/1 HID: sony: Fix work queue issues.
Don't initialize force-feedback for devices that don't support it to avoid calls to schedule_work() with an uninitialized work_struct.
Move the cancel_work_sync() call out of sony_destroy_ff() since the state worker is used for the LEDs even when force-feedback is disabled.
Remove sony_destroy_ff() to avoid a compiler warning since it is no longer used.
---
This is a bugfix for 3.14.
drivers/hid/hid-sony.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-)
drivers/hid/hid-sony.c +12 -15
@@ -42,6 +42,7 @@#define DUALSHOCK4_CONTROLLER_BT BIT(6)#define SONY_LED_SUPPORT (SIXAXIS_CONTROLLER_USB | BUZZ_CONTROLLER | DUALSHOCK4_CONTROLLER_USB) +#define SONY_FF_SUPPORT (SIXAXIS_CONTROLLER_USB | DUALSHOCK4_CONTROLLER_USB)#define MAX_LEDS 4
@@ -499,6 +500,7 @@ struct sony_sc {__u8 right;#endif +__u8 worker_initialized;__u8 led_state[MAX_LEDS ];__u8 led_count; };
@@ -993,22 +995,11 @@ static int sony_init_ff(struct hid_device *hdev) return input_ff_create_memless(input_dev, NULL, sony_play_effect); } -static void sony_destroy_ff (struct hid_device *hdev) -{ -struct sony_sc *sc =hid_get_drvdata (hdev); - -cancel_work_sync (&sc->state_worker); -} -#else static int sony_init_ff (struct hid_device *hdev) {return 0 ; } - -static void sony_destroy_ff (struct hid_device *hdev) -{ -}#endif static int sony_set_output_report (struct sony_sc *sc,int req_id,int req_size)
@@ -1077,6 +1068,8 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)if (sc->quirks &SIXAXIS_CONTROLLER_USB ) { hdev->hid_output_raw_report = sixaxis_usb_output_raw_report; ret =sixaxis_set_operational_usb (hdev); + + sc->worker_initialized =1 ;INIT_WORK (&sc->state_worker, sixaxis_state_worker); }else if (sc->quirks &SIXAXIS_CONTROLLER_BT )
@@ -1087,6 +1080,7 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)if (ret <0 ) goto err_stop; + sc->worker_initialized =1 ;INIT_WORK (&sc->state_worker, dualshock4_state_worker); }else { ret =0 ;
@@ -1101,9 +1095,11 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id) goto err_stop; } - ret =sony_init_ff (hdev); -if (ret <0 ) - goto err_stop; +if (sc->quirks &SONY_FF_SUPPORT ) { + ret =sony_init_ff (hdev); +if (ret <0 ) + goto err_stop; + }return 0 ; err_stop:
@@ -1120,7 +1116,8 @@ static void sony_remove(struct hid_device *hdev)if (sc->quirks &SONY_LED_SUPPORT )sony_leds_remove (hdev); -sony_destroy_ff (hdev); +if (sc->worker_initialized) +cancel_work_sync (&sc->state_worker);hid_hw_stop (hdev); }
Signature · 1 line
1.8.5.3
Quoted 8 lines · Frank Praznik
Don't initialize force-feedback for devices that don't support it to avoid calls to
schedule_work()with an uninitializedwork_struct.Move the
cancel_work_sync()call out ofsony_destroy_ff()since the state worker is used for the LEDs even when force-feedback is disabled.Remove
sony_destroy_ff()to avoid a compiler warning since it is no longer used.
Quoted 7 lines
Signed-off-by Frank Praznik <[email protected]>---
This is a bugfix for 3.14.
drivers/hid/hid-sony.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-)
<formletter>
This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read Documentation/stable_kernel_rules.txt for how to do this properly.
</formletter>
Hi Frank
Quoted 9 lines · Frank Praznik
Don't initialize force-feedback for devices that don't support it to avoid calls to
schedule_work()with an uninitializedwork_struct.Move the
cancel_work_sync()call out ofsony_destroy_ff()since the state worker is used for the LEDs even when force-feedback is disabled.Remove
sony_destroy_ff()to avoid a compiler warning since it is no longer used.Signed-off-by Frank Praznik <[email protected]>
Sorry, my comment might have been misleading. You have to add the "Cc:
<[email protected]>" line underneath/above your "Signed-off-by". This will send a notice to the stable guys once the patch is applied in Linus' tree.
But that's also described in the file Greg posted.
Cheers
David
Quoted 95 lines
---
This is a bugfix for 3.14.
drivers/hid/hid-sony.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-)drivers/hid/hid-sony.c +12
-16@@ -42,6 +42,7 @@#define DUALSHOCK4_CONTROLLER_BT BIT(6)#define SONY_LED_SUPPORT (SIXAXIS_CONTROLLER_USB | BUZZ_CONTROLLER | DUALSHOCK4_CONTROLLER_USB) +#define SONY_FF_SUPPORT (SIXAXIS_CONTROLLER_USB | DUALSHOCK4_CONTROLLER_USB)#define MAX_LEDS 4@@ -499,6 +500,7 @@ struct sony_sc {__u8 right;#endif +__u8 worker_initialized;__u8 led_state[MAX_LEDS ];__u8 led_count; };@@ -993,22 +995,11 @@ static int sony_init_ff(struct hid_device *hdev) return input_ff_create_memless(input_dev, NULL, sony_play_effect); } -static void sony_destroy_ff (struct hid_device *hdev) -{ -struct sony_sc *sc =hid_get_drvdata (hdev); - -cancel_work_sync (&sc->state_worker); -} -#else static int sony_init_ff (struct hid_device *hdev) {return 0 ; } - -static void sony_destroy_ff (struct hid_device *hdev) -{ -}#endif static int sony_set_output_report (struct sony_sc *sc,int req_id,int req_size)@@ -1077,6 +1068,8 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)if (sc->quirks &SIXAXIS_CONTROLLER_USB ) { hdev->hid_output_raw_report = sixaxis_usb_output_raw_report; ret =sixaxis_set_operational_usb (hdev); + + sc->worker_initialized =1 ;INIT_WORK (&sc->state_worker, sixaxis_state_worker); }else if (sc->quirks &SIXAXIS_CONTROLLER_BT )@@ -1087,6 +1080,7 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)if (ret <0 ) goto err_stop; + sc->worker_initialized =1 ;INIT_WORK (&sc->state_worker, dualshock4_state_worker); }else { ret =0 ;@@ -1101,9 +1095,11 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id) goto err_stop; } - ret =sony_init_ff (hdev); -if (ret <0 ) - goto err_stop; +if (sc->quirks &SONY_FF_SUPPORT ) { + ret =sony_init_ff (hdev); +if (ret <0 ) + goto err_stop; + }return 0 ; err_stop:@@ -1120,7 +1116,8 @@ static void sony_remove(struct hid_device *hdev)if (sc->quirks &SONY_LED_SUPPORT )sony_leds_remove (hdev); -sony_destroy_ff (hdev); +if (sc->worker_initialized) +cancel_work_sync (&sc->state_worker);hid_hw_stop (hdev); } --1.8.5.3
Quoted 18 lines · David Herrmann
Hi Frank
Quoted 9 lines · Frank Praznik
Don't initialize force-feedback for devices that don't support it to avoid calls to
schedule_work()with an uninitializedwork_struct.Move the
cancel_work_sync()call out ofsony_destroy_ff()since the state worker is used for the LEDs even when force-feedback is disabled.Remove
sony_destroy_ff()to avoid a compiler warning since it is no longer used.Signed-off-by Frank Praznik <[email protected]>Sorry, my comment might have been misleading. You have to add the "Cc:
<[email protected]>" line underneath/above your "Signed-off-by". This will send a notice to the stable guys once the patch is applied in Linus' tree.
Quoted 5 lines
But that's also described in the file Greg posted.
Cheers
David
Actually, does this even need to go into stable? The issue doesn't exist below kernel 3.14 since the LED system wasn't added until commit 0a286ef278529f2bc4f4bb27c4cf99c05999c818 in December. Could this just go into for-3.14/upstream-fixes and for-linus with the other pending fixes?
Hi
Quoted 21 lines · Frank Praznik
Quoted 20 lines · David Herrmann
Hi Frank
Quoted 9 lines · Frank Praznik
Don't initialize force-feedback for devices that don't support it to avoid calls to
schedule_work()with an uninitializedwork_struct.Move the
cancel_work_sync()call out ofsony_destroy_ff()since the state worker is used for the LEDs even when force-feedback is disabled.Remove
sony_destroy_ff()to avoid a compiler warning since it is no longer used.Signed-off-by Frank Praznik <[email protected]>Sorry, my comment might have been misleading. You have to add the "Cc:
<[email protected]>" line underneath/above your "Signed-off-by". This will send a notice to the stable guys once the patch is applied in Linus' tree.But that's also described in the file Greg posted.
Quoted 8 lines
Quoted 3 lines
Cheers
DavidActually, does this even need to go into stable? The issue doesn't exist below kernel 3.14 since the LED system wasn't added until commit
0a286ef278529f2bc4f4bb27c4cf99c05999c818in December. Could this just go into for-3.14/upstream-fixes and for-linus with the other pending fixes?
Sure.
Thanks
David
Jiri Kosina
AppliedQuoted 9 lines · Frank Praznik
Don't initialize force-feedback for devices that don't support it to avoid calls to
schedule_work()with an uninitializedwork_struct.Move the
cancel_work_sync()call out ofsony_destroy_ff()since the state worker is used for the LEDs even when force-feedback is disabled.Remove
sony_destroy_ff()to avoid a compiler warning since it is no longer used.Signed-off-by Frank Praznik <[email protected]>
Queued for 3.14 (without the -stable annotation), thanks.
Signature · 2 lines
Jiri Kosina SUSE Labs