Skip to content

Commit

Permalink
backlight: lcd: Fix race condition during register
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Uwe Kleine-König authored and Lee Jones committed Jan 4, 2017
1 parent 7ce7d89 commit cc21942
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/video/backlight/lcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit cc21942

Please sign in to comment.