From: Janne Kanniainen Date: Thu, 3 Jul 2014 17:17:08 +0000 (-0700) Subject: HID: gt683r: fix race condition X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c3883ae918c8754f7c251564d63211e1d5648b08;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git HID: gt683r: fix race condition This will fix race condition noticed by Oliver Neukum. Sysfs files are created before mutex and work are initialized. Signed-off-by: Janne Kanniainen Reviewed-by: Johan Hovold Signed-off-by: Bryan Wu --- diff --git a/drivers/hid/hid-gt683r.c b/drivers/hid/hid-gt683r.c index 077f7a19c9d5..073bd80ec839 100644 --- a/drivers/hid/hid-gt683r.c +++ b/drivers/hid/hid-gt683r.c @@ -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: