]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.14.69/extcon-release-locking-when-sending-the-notification-of-connector-state.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.14.69 / extcon-release-locking-when-sending-the-notification-of-connector-state.patch
1 From 8a9dbb779fe882325b9a0238494a7afaff2eb444 Mon Sep 17 00:00:00 2001
2 From: Chanwoo Choi <cw00.choi@samsung.com>
3 Date: Thu, 14 Jun 2018 11:16:29 +0900
4 Subject: extcon: Release locking when sending the notification of connector state
5
6 From: Chanwoo Choi <cw00.choi@samsung.com>
7
8 commit 8a9dbb779fe882325b9a0238494a7afaff2eb444 upstream.
9
10 Previously, extcon used the spinlock before calling the notifier_call_chain
11 to prevent the scheduled out of task and to prevent the notification delay.
12 When spinlock is locked for sending the notification, deadlock issue
13 occured on the side of extcon consumer device. To fix this issue,
14 extcon consumer device should always use the work. it is always not
15 reasonable to use work.
16
17 To fix this issue on extcon consumer device, release locking when sending
18 the notification of connector state.
19
20 Fixes: ab11af049f88 ("extcon: Add the synchronization extcon APIs to support the notification")
21 Cc: stable@vger.kernel.org
22 Cc: Roger Quadros <rogerq@ti.com>
23 Cc: Kishon Vijay Abraham I <kishon@ti.com>
24 Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
25 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
26
27 ---
28 drivers/extcon/extcon.c | 3 ++-
29 1 file changed, 2 insertions(+), 1 deletion(-)
30
31 --- a/drivers/extcon/extcon.c
32 +++ b/drivers/extcon/extcon.c
33 @@ -433,8 +433,8 @@ int extcon_sync(struct extcon_dev *edev,
34 return index;
35
36 spin_lock_irqsave(&edev->lock, flags);
37 -
38 state = !!(edev->state & BIT(index));
39 + spin_unlock_irqrestore(&edev->lock, flags);
40
41 /*
42 * Call functions in a raw notifier chain for the specific one
43 @@ -448,6 +448,7 @@ int extcon_sync(struct extcon_dev *edev,
44 */
45 raw_notifier_call_chain(&edev->nh_all, state, edev);
46
47 + spin_lock_irqsave(&edev->lock, flags);
48 /* This could be in interrupt handler */
49 prop_buf = (char *)get_zeroed_page(GFP_ATOMIC);
50 if (!prop_buf) {