backlight: lcd: Fix race condition during register
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Wed, 6 Jul 2016 17:33:05 +0000 (19:33 +0200)
committerLee Jones <lee.jones@linaro.org>
Wed, 4 Jan 2017 11:37:31 +0000 (11:37 +0000)
Once device_register is called for a device its attributes might be
accessed. As the callbacks of a lcd device's attributes make use of the
lcd_ops, the respective member must be setup before calling
device_register.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
drivers/video/backlight/lcd.c

index 7de847df224fd2c24ac62b4c97d46c174f5e026f..4b40c6a4d44190a554b9676b3cb9ced5579789ff 100644 (file)
@@ -226,6 +226,8 @@ struct lcd_device *lcd_device_register(const char *name, struct device *parent,
        dev_set_name(&new_ld->dev, "%s", name);
        dev_set_drvdata(&new_ld->dev, devdata);
 
+       new_ld->ops = ops;
+
        rc = device_register(&new_ld->dev);
        if (rc) {
                put_device(&new_ld->dev);
@@ -238,8 +240,6 @@ struct lcd_device *lcd_device_register(const char *name, struct device *parent,
                return ERR_PTR(rc);
        }
 
-       new_ld->ops = ops;
-
        return new_ld;
 }
 EXPORT_SYMBOL(lcd_device_register);