Benjamin Tissoires
3ffa6583e2
power: remove possible deadlock when unregistering power_supply
If a device gets removed right after having registered a power_supply node,
we might enter in a deadlock between the remove call (that has a lock on
the parent device) and the deferred register work.
Allow the deferred register work to exit without taking the lock when
we are in the remove state.
Stack trace on a Ubuntu 16.04:
[16072.109121] INFO: task kworker/u16:2:1180 blocked for more than 120 seconds.
[16072.109127] Not tainted 4.13.0-41-generic #46~16.04.1-Ubuntu
[16072.109129] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[16072.109132] kworker/u16:2 D 0 1180 2 0x80000000
[16072.109142] Workqueue: events_power_efficient power_supply_deferred_register_work
[16072.109144] Call Trace:
[16072.109152] __schedule+0x3d6/0x8b0
[16072.109155] schedule+0x36/0x80
[16072.109158] schedule_preempt_disabled+0xe/0x10
[16072.109161] __mutex_lock.isra.2+0x2ab/0x4e0
[16072.109166] __mutex_lock_slowpath+0x13/0x20
[16072.109168] ? __mutex_lock_slowpath+0x13/0x20
[16072.109171] mutex_lock+0x2f/0x40
[16072.109174] power_supply_deferred_register_work+0x2b/0x50
[16072.109179] process_one_work+0x15b/0x410
[16072.109182] worker_thread+0x4b/0x460
[16072.109186] kthread+0x10c/0x140
[16072.109189] ? process_one_work+0x410/0x410
[16072.109191] ? kthread_create_on_node+0x70/0x70
[16072.109194] ret_from_fork+0x35/0x40
[16072.109199] INFO: task test:2257 blocked for more than 120 seconds.
[16072.109202] Not tainted 4.13.0-41-generic #46~16.04.1-Ubuntu
[16072.109204] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[16072.109206] test D 0 2257 2256 0x00000004
[16072.109208] Call Trace:
[16072.109211] __schedule+0x3d6/0x8b0
[16072.109215] schedule+0x36/0x80
[16072.109218] schedule_timeout+0x1f3/0x360
[16072.109221] ? check_preempt_curr+0x5a/0xa0
[16072.109224] ? ttwu_do_wakeup+0x1e/0x150
[16072.109227] wait_for_completion+0xb4/0x140
[16072.109230] ? wait_for_completion+0xb4/0x140
[16072.109233] ? wake_up_q+0x70/0x70
[16072.109236] flush_work+0x129/0x1e0
[16072.109240] ? worker_detach_from_pool+0xb0/0xb0
[16072.109243] __cancel_work_timer+0x10f/0x190
[16072.109247] ? device_del+0x264/0x310
[16072.109250] ? __wake_up+0x44/0x50
[16072.109253] cancel_delayed_work_sync+0x13/0x20
[16072.109257] power_supply_unregister+0x37/0xb0
[16072.109260] devm_power_supply_release+0x11/0x20
[16072.109263] release_nodes+0x110/0x200
[16072.109266] devres_release_group+0x7c/0xb0
[16072.109274] wacom_remove+0xc2/0x110 [wacom]
[16072.109279] hid_device_remove+0x6e/0xd0 [hid]
[16072.109284] device_release_driver_internal+0x158/0x210
[16072.109288] device_release_driver+0x12/0x20
[16072.109291] bus_remove_device+0xec/0x160
[16072.109293] device_del+0x1de/0x310
[16072.109298] hid_destroy_device+0x27/0x60 [hid]
[16072.109303] usbhid_disconnect+0x51/0x70 [usbhid]
[16072.109308] usb_unbind_interface+0x77/0x270
[16072.109311] device_release_driver_internal+0x158/0x210
[16072.109315] device_release_driver+0x12/0x20
[16072.109318] usb_driver_release_interface+0x77/0x80
[16072.109321] proc_ioctl+0x20f/0x250
[16072.109325] usbdev_do_ioctl+0x57f/0x1140
[16072.109327] ? __wake_up+0x44/0x50
[16072.109331] usbdev_ioctl+0xe/0x20
[16072.109336] do_vfs_ioctl+0xa4/0x600
[16072.109339] ? vfs_write+0x15a/0x1b0
[16072.109343] SyS_ioctl+0x79/0x90
[16072.109347] entry_SYSCALL_64_fastpath+0x24/0xab
[16072.109349] RIP: 0033:0x7f20da807f47
[16072.109351] RSP: 002b:00007ffc422ae398 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
[16072.109353] RAX: ffffffffffffffda RBX: 00000000010b8560 RCX: 00007f20da807f47
[16072.109355] RDX: 00007ffc422ae3a0 RSI: 00000000c0105512 RDI: 0000000000000009
[16072.109356] RBP: 0000000000000000 R08: 00007ffc422ae3e0 R09: 0000000000000010
[16072.109357] R10: 00000000000000a6 R11: 0000000000000246 R12: 0000000000000000
[16072.109359] R13: 00000000010b8560 R14: 00007ffc422ae2e0 R15: 0000000000000000
Reported-and-tested-by: Richard Hughes <rhughes@redhat.com>
Tested-by: Aaron Skomra <Aaron.Skomra@wacom.com>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Fixes: 7f1a57fdd6 ("power_supply: Fix possible NULL pointer dereference on early uevent")
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-07-06 16:03:21 +02:00
..
2018-05-14 07:05:16 -07:00
2018-06-04 20:46:00 +02:00
2018-05-30 12:48:49 -07:00
2018-05-29 10:15:33 +05:30
2018-05-25 18:23:56 +02:00
2018-05-28 23:05:11 -04:00
2018-05-23 14:01:03 +02:00
2018-06-09 10:32:39 -07:00
2018-05-13 15:59:01 +02:00
2018-05-16 07:24:30 +02:00
2018-06-11 07:23:19 -07:00
2018-05-10 16:08:25 -04:00
2018-06-07 13:04:07 -07:00
2018-06-06 18:39:49 -07:00
2018-06-08 10:39:20 -07:00
2018-06-11 14:24:32 -07:00
2018-05-21 18:07:05 +01:00
2018-05-17 16:11:39 -04:00
2018-06-17 05:25:18 +09:00
2018-04-25 23:11:47 +02:00
2018-06-05 10:48:09 -04:00
2018-06-07 14:23:08 +01:00
2018-06-03 17:37:15 -07:00
2018-06-07 17:34:35 -07:00
2018-06-11 18:19:45 -07:00
2018-05-11 21:48:07 +05:30
2018-05-11 11:34:41 +09:00
2018-06-12 10:09:03 -07:00
2018-06-06 09:08:38 -07:00
2018-06-08 11:10:58 -07:00
2018-06-02 19:29:27 -05:00
2018-05-26 09:16:44 +02:00
2018-05-31 17:34:01 +01:00
2018-06-15 18:10:01 -03:00
2018-06-15 18:10:01 -03:00
2018-05-16 07:23:35 +02:00
2018-04-27 09:48:44 +02:00
2018-05-14 17:45:21 -04:00
2018-04-30 13:25:14 +01:00
2018-05-23 13:23:39 -04:00
2018-06-08 13:36:19 -07:00
2018-06-02 20:35:00 -06:00
2018-06-14 17:01:45 +02:00
2018-06-15 08:13:35 -06:00
2018-05-30 12:38:40 +02:00
2018-04-30 10:55:56 +02:00
2018-05-30 12:38:40 +02:00
2018-05-26 19:46:15 -04:00
2018-05-28 17:41:02 +02:00
2018-06-03 18:22:41 -07:00
2018-05-23 13:23:40 -04:00
2018-06-05 09:43:09 -04:00
2018-05-29 13:00:25 -06:00
2018-05-29 13:00:25 -06:00
2018-05-09 17:25:13 +02:00
2018-06-01 18:37:33 -07:00
2018-06-05 18:06:24 +01:00
2018-04-26 14:29:05 -07:00
2018-04-26 14:29:05 -07:00
2018-06-15 18:10:01 -03:00
2018-06-09 12:06:24 -07:00
2018-06-04 20:27:54 -07:00
2018-05-31 16:41:41 -07:00
2018-05-31 16:41:41 -07:00
2018-05-31 16:41:41 -07:00
2018-06-04 17:28:20 -04:00
2018-05-14 16:19:59 +02:00
2018-05-14 08:57:47 +02:00
2018-05-03 13:55:47 +02:00
2018-05-23 10:37:08 +02:00
2018-05-30 23:13:00 +02:00
2018-05-14 13:46:04 -04:00
2018-06-08 17:21:52 -07:00
2018-05-11 15:36:37 -04:00
2018-04-27 14:34:51 +02:00
2018-05-22 23:18:31 -07:00
2018-06-06 17:27:14 -07:00
2018-05-08 13:02:42 +02:00
2018-05-19 08:46:12 +02:00
2018-05-03 12:38:39 +02:00
2018-05-13 15:59:00 +02:00
2018-05-28 12:48:25 +02:00
2018-05-19 08:46:12 +02:00
2018-05-14 08:57:48 +02:00
2018-06-01 07:38:16 -06:00
2018-04-27 11:53:02 -04:00
2018-05-17 22:44:57 +09:00
2018-06-03 07:46:56 -07:00
2018-05-14 16:44:41 +02:00
2018-06-15 07:31:07 +09:00
2018-06-11 10:16:13 -07:00
2018-06-11 10:16:13 -07:00
2018-05-18 14:58:22 +02:00
2018-06-15 18:10:01 -03:00
2018-04-26 09:02:01 -06:00
2018-06-07 17:34:38 -07:00
2018-06-08 10:25:50 +02:00
2018-06-07 17:34:37 -07:00
2018-05-18 21:51:37 +02:00
2018-04-26 14:53:32 +02:00
2018-05-24 12:04:32 -07:00
2018-06-10 13:01:12 -07:00
2018-05-22 13:42:16 +02:00
2018-06-04 10:58:12 -07:00
2018-05-25 14:37:20 -04:00
2018-04-25 08:26:19 -07:00
2018-06-03 11:00:52 -04:00
2018-05-29 10:12:45 -04:00
2018-05-15 16:34:52 +02:00
2018-05-14 11:25:28 +02:00
2018-06-01 18:37:33 -07:00
2018-05-09 06:55:44 +02:00
2018-06-04 14:20:39 -04:00
2018-05-09 12:21:46 -05:00
2018-05-14 11:25:27 +02:00
2018-04-26 22:26:39 +02:00
2018-06-10 09:44:53 -07:00
2018-05-13 15:59:00 +02:00
2018-05-14 13:46:04 -04:00
2018-06-15 07:55:24 +09:00
2018-06-09 10:32:39 -07:00
2018-06-07 17:34:36 -07:00
2018-05-03 07:38:05 +02:00
2018-06-01 19:18:26 +02:00
2018-06-10 13:01:12 -07:00
2018-06-01 07:43:53 -06:00
2018-06-13 00:03:17 +09:00
2018-05-04 12:48:54 -07:00
2018-06-05 08:50:16 -04:00
2018-06-15 07:55:25 +09:00
2018-06-07 17:34:35 -07:00
2018-06-07 17:34:36 -07:00
2018-05-14 13:14:23 -06:00
2018-06-08 17:21:52 -07:00
2018-06-07 17:34:37 -07:00
2018-06-12 16:19:22 -07:00
2018-05-11 12:13:26 +09:00
2018-06-07 17:34:39 -07:00
2018-06-05 12:26:41 -04:00
2018-05-13 15:58:59 +02:00
2018-05-15 08:11:15 +02:00
2018-06-15 15:27:09 +01:00
2018-06-06 18:39:49 -07:00
2018-05-23 14:48:44 -04:00
2018-06-05 12:42:19 -04:00
2018-06-12 19:12:43 +02:00
2018-05-31 15:03:11 -04:00
2018-06-04 12:07:07 -04:00
2018-05-25 18:12:11 -07:00
2018-05-05 00:51:44 +02:00
2018-05-30 10:11:34 +02:00
2018-05-14 16:27:08 +02:00
2018-06-01 14:37:35 +02:00
2018-05-14 16:20:48 +02:00
2018-05-02 08:31:07 -07:00
2018-05-03 16:25:08 +02:00
2018-05-30 11:35:13 -05:00
2018-05-11 17:28:45 -07:00
2018-06-05 12:16:51 -07:00
2018-06-07 17:34:36 -07:00
2018-06-07 17:34:37 -07:00
2018-06-04 12:08:06 -05:00
2018-06-06 16:10:45 -05:00
2018-05-30 11:35:23 -05:00
2018-05-15 15:51:38 +01:00
2018-05-18 16:40:50 +01:00
2018-06-07 12:45:58 -07:00
2018-05-16 11:45:16 +02:00
2018-06-06 18:39:49 -07:00
2018-06-07 17:34:35 -07:00
2018-05-24 15:35:58 -04:00
2018-05-09 11:51:46 +10:00
2018-05-30 15:33:32 -06:00
2018-05-03 16:22:18 +02:00
2018-06-06 09:09:22 +02:00
2018-05-09 10:15:21 +05:30
2018-06-12 10:24:13 +02:00
2018-05-26 09:16:44 +02:00
2018-07-06 16:03:21 +02:00
2018-05-18 11:46:15 +01:00
2018-05-17 12:47:21 +02:00
2018-05-31 00:13:56 +08:00
2018-06-05 16:57:31 -07:00
2018-04-25 10:40:51 -05:00
2018-04-30 10:50:44 +01:00
2018-04-25 00:12:05 -05:00
2018-05-11 17:28:45 -07:00
2018-05-11 17:28:45 -07:00
2018-06-15 18:10:01 -03:00
2018-05-31 14:59:19 -04:00
2018-06-10 06:14:01 +02:00
2018-05-22 16:12:26 -07:00
2018-05-22 16:12:26 -07:00
2018-05-25 18:35:59 +01:00
2018-04-25 16:43:55 -07:00
2018-06-04 17:28:20 -04:00
2018-06-03 17:37:11 -07:00
2018-04-24 19:50:10 -07:00
2018-05-16 21:08:42 +02:00
2018-05-16 11:45:16 +02:00
2018-05-24 11:00:39 -06:00
2018-06-15 07:55:24 +09:00
2018-05-10 10:49:40 +01:00
2018-05-05 00:51:44 +02:00
2018-05-04 12:48:54 -07:00
2018-05-16 07:24:30 +02:00
2018-04-30 05:14:55 -07:00
2018-06-07 17:34:35 -07:00
2018-04-26 19:51:14 -05:00
2018-05-17 12:46:54 -04:00
2018-06-06 18:39:49 -07:00
2018-06-07 17:34:34 -07:00
2018-06-15 07:55:23 +09:00
2018-06-07 17:34:37 -07:00
2018-05-03 15:55:23 -07:00
2018-05-05 11:41:58 -04:00
2018-05-15 08:11:15 +02:00
2018-05-15 10:27:56 -07:00
2018-05-30 10:11:34 +02:00
2018-05-30 10:11:34 +02:00
2018-06-14 12:21:18 +09:00
2018-06-05 16:57:31 -07:00
2018-05-15 21:47:09 +03:00
2018-05-15 08:32:42 +02:00
2018-04-28 15:01:14 -07:00
2018-06-04 17:45:38 -07:00
2018-06-06 11:58:31 +02:00
2018-05-18 11:40:27 -04:00
2018-05-30 14:46:17 +08:00
2018-05-25 12:27:53 +01:00
2018-05-19 13:57:31 +02:00
2018-05-19 13:57:31 +02:00
2018-04-26 14:53:32 +02:00
2018-05-19 13:57:32 +02:00
2018-05-19 13:57:33 +02:00
2018-04-29 08:45:53 -07:00
2018-06-06 18:39:49 -07:00
2018-04-25 10:40:51 -05:00
2018-06-15 18:10:01 -03:00
2018-05-16 07:24:30 +02:00
2018-06-05 16:14:12 -07:00
2018-06-07 17:34:38 -07:00
2018-05-07 23:25:24 -04:00
2018-04-26 15:08:04 -04:00
2018-05-14 16:16:35 +02:00
2018-05-22 23:17:03 -07:00
2018-05-23 13:23:39 -04:00
2018-05-31 12:48:17 +02:00
2018-06-07 17:34:38 -07:00
2018-06-07 16:15:38 -04:00
2018-06-07 20:54:23 +03:00
2018-04-25 20:33:19 +03:00
2018-06-05 12:16:51 -07:00
2018-05-03 09:25:47 -06:00
2018-05-18 08:47:13 -07:00
2018-05-14 09:51:34 -04:00