android_kernel_motorola_sm6225/drivers/leds
Luis Henriques 6d71021ab3 leds: class: ensure workqueue is initialized before setting brightness
An application can try to set brightness before all the initialization is
done, in particular before the workqueue is initialized with the call to
led_init_core().  Here's a WARNING easy to trigger:

[   36.780813] WARNING: CPU: 3 PID: 1411 at ../kernel/workqueue.c:1444 __queue_work+0x37b/0x420
[   36.780815] Modules linked in: ...
[   36.780868] CPU: 3 PID: 1411 Comm: systemd-backlig Not tainted 4.16.9-1-default #1 openSUSE Tumbleweed (unreleased)
[   36.780868] Hardware name: Dell Inc. Precision 5510/0N8J4R, BIOS 1.6.1 12/11/2017
[   36.780870] RIP: 0010:__queue_work+0x37b/0x420
[   36.780871] RSP: 0018:ffffaced048b7d78 EFLAGS: 00010086
[   36.780873] RAX: 0000000000000000 RBX: ffffffffb3f01440 RCX: 0000000000000000
[   36.780873] RDX: ffffffffc05a90d8 RSI: 0000000000000000 RDI: ffff8eac7dce2700
[   36.780874] RBP: ffff8ea547c16400 R08: ffff8ea547800000 R09: ffff8eac7dc22700
[   36.780875] R10: 0000000000000000 R11: 0000000000000040 R12: 0000000000000003
[   36.780876] R13: 0000000000000200 R14: ffffffffc05a90d0 R15: ffff8eac7dce8600
[   36.780877] FS:  00007f871e61cf40(0000) GS:ffff8eac7dcc0000(0000) knlGS:0000000000000000
[   36.780878] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   36.780879] CR2: 000055c91115e308 CR3: 0000000883ee0005 CR4: 00000000003606e0
[   36.780880] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[   36.780880] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[   36.780881] Call Trace:
[   36.780886]  queue_work_on+0x81/0x90
[   36.780889]  brightness_store+0x5d/0x90
[   36.780892]  kernfs_fop_write+0x105/0x180
[   36.780894]  __vfs_write+0x26/0x150
[   36.780897]  ? common_file_perm+0x51/0x150
[   36.780900]  ? security_file_permission+0x3c/0xb0
[   36.780901]  vfs_write+0xad/0x1a0
[   36.780903]  SyS_write+0x42/0x90
[   36.780906]  do_syscall_64+0x76/0x140
[   36.780908]  entry_SYSCALL_64_after_hwframe+0x42/0xb7
[   36.780910] RIP: 0033:0x7f871dd04c94
[   36.780910] RSP: 002b:00007ffeb3a57d38 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
[   36.780912] RAX: ffffffffffffffda RBX: 000055c91115c810 RCX: 00007f871dd04c94
[   36.780912] RDX: 0000000000000001 RSI: 000055c91115c810 RDI: 0000000000000004
[   36.780913] RBP: 00007ffeb3a57e10 R08: 0000000000000003 R09: 0000000000000000
[   36.780914] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001
[   36.780914] R13: 000055c911158f30 R14: 000055c90f3a9a4e R15: 0000000000000004
[   36.780917] Code: 74 18 e8 49 80 00 00 48 85 c0 74 0e 48 8b 40 20 48 3b 68 08
0f 84 c2 fc ff ff 0f 0b 48 83 c4 10 5b 5d 41 5c 41 5d 41 5e 41 5f c3 <0f> 0b e9
82 fd ff ff 83 cd 02 49 8d 57 60 e9 69 fd ff ff 80 3d
[   36.780942] ---[ end trace 1fce4edad54c4017 ]---

This patch initializes and acquires the led_access mutex early in the
of_led_classdev_register function, so that any application trying to write
to sysfs to set brightness will block until initialization ends.

Signed-off-by: Luis Henriques <lhenriques@suse.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
2018-05-24 22:08:26 +02:00
..
trigger leds: Extends disk trigger for reads and writes 2018-03-11 20:01:55 +01:00
Kconfig leds: lm3601x: Introduce the lm3601x LED driver 2018-05-23 21:44:47 +02:00
led-class-flash.c
led-class.c leds: class: ensure workqueue is initialized before setting brightness 2018-05-24 22:08:26 +02:00
led-core.c leds: core: Fix regression caused by commit 2b83ff96f5 2018-01-07 13:27:07 +01:00
led-triggers.c
leds-88pm860x.c
leds-aat1290.c LED updates for 4.14 2017-09-07 14:33:13 -07:00
leds-adp5520.c
leds-apu.c leds: Fix wrong dmi_match on PC Engines APU LEDs 2018-03-20 20:28:00 +01:00
leds-as3645a.c leds: as3645a: Fix line over 80 characters 2018-01-08 21:28:11 +01:00
leds-asic3.c
leds-bcm6328.c leds: bcm6328: fix signal source assignment for leds 4 to 7 2017-06-13 20:36:56 +02:00
leds-bcm6358.c
leds-bd2802.c
leds-blinkm.c leds: blinkm: avoid uninitialized data use 2018-01-08 21:28:10 +01:00
leds-clevo-mail.c dmi: Mark all struct dmi_system_id instances const 2017-09-14 11:59:30 +02:00
leds-cobalt-qube.c
leds-cobalt-raq.c leds: leds-cobalt-raq: use builtin_platform_driver 2016-11-23 16:38:01 +01:00
leds-cpcap.c leds: cpcap: new driver 2017-03-29 21:02:27 +02:00
leds-cr0014114.c leds: add LED driver for CR0014114 board 2018-04-16 20:16:24 +02:00
leds-da903x.c
leds-da9052.c
leds-dac124s085.c
leds-fsg.c
leds-gpio-register.c
leds-gpio.c leds: gpio: Allow LED to retain state at shutdown 2017-08-29 21:10:40 +02:00
leds-hp6xx.c
leds-ipaq-micro.c
leds-is31fl32xx.c leds: Convert to using %pOF instead of full_name 2017-08-12 23:50:07 +02:00
leds-is31fl319x.c
leds-ktd2692.c leds: ktd2692: avoid harmless maybe-uninitialized warning 2017-01-26 21:16:38 +01:00
leds-lm355x.c
leds-lm3530.c
leds-lm3533.c leds: lm3533: constify attribute_group structure 2017-08-29 21:10:37 +02:00
leds-lm3601x.c leds: lm3601x: Introduce the lm3601x LED driver 2018-05-23 21:44:47 +02:00
leds-lm3642.c
leds-lm3692x.c leds: lm3692x: Introduce LM3692x dual string driver 2018-01-08 21:28:11 +01:00
leds-locomo.c
leds-lp55xx-common.c
leds-lp55xx-common.h
leds-lp3944.c
leds-lp3952.c leds: lp3952: Use 'if (ret)' pattern 2017-03-23 20:33:59 +01:00
leds-lp5521.c leds: lp5521: make several arrays static const 2017-08-29 21:10:38 +02:00
leds-lp5523.c leds: lp55xx: fix spelling mistake: 'cound' -> 'could' 2017-10-30 20:39:33 +01:00
leds-lp5562.c leds: lp5562: make several arrays static const 2017-08-29 21:10:39 +02:00
leds-lp8501.c leds: lp8501: make several arrays static const 2017-08-29 21:10:39 +02:00
leds-lp8788.c
leds-lp8860.c leds: lp8860: Various fixes to align with LED framework 2018-01-08 21:28:12 +01:00
leds-lt3593.c
leds-max8997.c
leds-max77693.c media: v4l2-flash-led-class: Create separate sub-devices for indicators 2017-08-26 20:26:35 -04:00
leds-mc13783.c leds: mc13783: Fix MC13892 keypad led access 2016-11-22 12:07:03 +01:00
leds-menf21bmc.c
leds-mlxcpld.c leds: verify vendor and change license in mlxcpld driver 2016-11-22 12:07:04 +01:00
leds-mlxreg.c leds: add driver for support Mellanox regmap LEDs for BMC and x86 platform 2018-02-19 21:09:20 +01:00
leds-mt6323.c leds: mt6323: Fix an off by one bug in probe 2017-03-23 20:23:57 +01:00
leds-net48xx.c
leds-netxbig.c leds: netxbig: fix module autoload for OF registration 2016-11-30 11:10:27 +01:00
leds-nic78bx.c leds: Add user LED driver for NIC78bx device 2016-11-22 12:07:04 +01:00
leds-ns2.c
leds-ot200.c
leds-pca955x.c leds: pca955x: Don't invert requested value in pca955x_gpio_set_value() 2017-10-06 21:31:03 +02:00
leds-pca963x.c leds: pca963x: Add bindings to invert polarity 2017-05-14 13:01:29 +02:00
leds-pca9532.c leds: pca9532: Extend pca9532 device tree support 2017-04-19 20:27:50 +02:00
leds-pm8058.c leds: pm8058: Silence pointer to integer size warning 2017-12-01 08:57:42 +00:00
leds-powernv.c leds: powernv: Delete an error message for a failed memory allocation in powernv_led_create() 2017-08-29 21:10:39 +02:00
leds-pwm.c leds: pwm: Remove unneeded header file 2018-01-08 21:28:10 +01:00
leds-rb532.c
leds-regulator.c
leds-s3c24xx.c
leds-sc27xx-bltc.c leds: sc27xx: Fix return value check in sc27xx_led_probe() 2018-05-22 21:57:59 +02:00
leds-ss4200.c dmi: Mark all struct dmi_system_id instances const 2017-09-14 11:59:30 +02:00
leds-sunfire.c
leds-syscon.c
leds-tca6507.c leds: tca6507: Remove unnecessary reg check 2017-10-09 20:39:54 +02:00
leds-tlc591xx.c leds: tlc591xx: add missing of_node_put 2017-07-16 18:45:43 +02:00
leds-wm831x-status.c leds: wm831x-status: Use sysfs_match_string() helper 2018-05-03 21:50:13 +02:00
leds-wm8350.c
leds-wrap.c
leds.h
Makefile leds: lm3601x: Introduce the lm3601x LED driver 2018-05-23 21:44:47 +02:00
uleds.c vfs: do bulk POLL* -> EPOLL* replacement 2018-02-11 14:34:03 -08:00