diff options
author | Alexey Khoroshilov <khoroshilov@ispras.ru> | 2014-05-06 17:26:04 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-05-27 17:08:46 -0400 |
commit | a0f104644ec27ce5bbb36e950eb426dba9a3ad44 (patch) | |
tree | 1b6a9e19b07eda7cf09408403cb84822c58436da | |
parent | 8a0427d192e6043834414210dd14cc1289daff18 (diff) |
w1: do not unlock unheld list_mutex in __w1_remove_master_device()
w1_process_callbacks() expects to be called with dev->list_mutex held,
but it is the fact only in w1_process(). __w1_remove_master_device()
calls w1_process_callbacks() after it releases list_mutex.
The patch fixes __w1_remove_master_device() to acquire list_mutex
for w1_process_callbacks().
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Acked-by: David Fries <david@fries.net>
Acked-by: Evgeniy Polyakov <zbr@ioremap.net>
Cc: stable <stable@vger.kernel.org> # 3.15
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/w1/w1.c | 2 | ||||
-rw-r--r-- | drivers/w1/w1_int.c | 4 |
2 files changed, 6 insertions, 0 deletions
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c index ff52618cafbe..5d7341520544 100644 --- a/drivers/w1/w1.c +++ b/drivers/w1/w1.c | |||
@@ -1078,6 +1078,8 @@ static void w1_search_process(struct w1_master *dev, u8 search_type) | |||
1078 | * w1_process_callbacks() - execute each dev->async_list callback entry | 1078 | * w1_process_callbacks() - execute each dev->async_list callback entry |
1079 | * @dev: w1_master device | 1079 | * @dev: w1_master device |
1080 | * | 1080 | * |
1081 | * The w1 master list_mutex must be held. | ||
1082 | * | ||
1081 | * Return: 1 if there were commands to executed 0 otherwise | 1083 | * Return: 1 if there were commands to executed 0 otherwise |
1082 | */ | 1084 | */ |
1083 | int w1_process_callbacks(struct w1_master *dev) | 1085 | int w1_process_callbacks(struct w1_master *dev) |
diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c index 9b084db739c7..728039d2efe1 100644 --- a/drivers/w1/w1_int.c +++ b/drivers/w1/w1_int.c | |||
@@ -219,9 +219,13 @@ void __w1_remove_master_device(struct w1_master *dev) | |||
219 | 219 | ||
220 | if (msleep_interruptible(1000)) | 220 | if (msleep_interruptible(1000)) |
221 | flush_signals(current); | 221 | flush_signals(current); |
222 | mutex_lock(&dev->list_mutex); | ||
222 | w1_process_callbacks(dev); | 223 | w1_process_callbacks(dev); |
224 | mutex_unlock(&dev->list_mutex); | ||
223 | } | 225 | } |
226 | mutex_lock(&dev->list_mutex); | ||
224 | w1_process_callbacks(dev); | 227 | w1_process_callbacks(dev); |
228 | mutex_unlock(&dev->list_mutex); | ||
225 | 229 | ||
226 | memset(&msg, 0, sizeof(msg)); | 230 | memset(&msg, 0, sizeof(msg)); |
227 | msg.id.mst.id = dev->id; | 231 | msg.id.mst.id = dev->id; |