HID: gt683r: fix race condition
authorJanne Kanniainen <janne.kanniainen@gmail.com>
Thu, 3 Jul 2014 17:17:08 +0000 (10:17 -0700)
committerBryan Wu <cooloney@gmail.com>
Thu, 3 Jul 2014 18:12:16 +0000 (11:12 -0700)
This will fix race condition noticed by Oliver Neukum. Sysfs files are
created before mutex and work are initialized.

Signed-off-by: Janne Kanniainen <janne.kanniainen@gmail.com>
Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
drivers/hid/hid-gt683r.c

index 077f7a19c9d5fb5ef96ab51e76199d13a1865edf..073bd80ec839729d70c9a06575c7732aa1070a44 100644 (file)
@@ -227,6 +227,9 @@ static int gt683r_led_probe(struct hid_device *hdev,
        if (!led)
                return -ENOMEM;
 
+       mutex_init(&led->lock);
+       INIT_WORK(&led->work, gt683r_led_work);
+
        led->mode = GT683R_LED_NORMAL;
        led->hdev = hdev;
        hid_set_drvdata(hdev, led);
@@ -271,9 +274,6 @@ static int gt683r_led_probe(struct hid_device *hdev,
                goto fail;
        }
 
-       mutex_init(&led->lock);
-       INIT_WORK(&led->work, gt683r_led_work);
-
        return 0;
 
 fail: