]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
w1: do not unlock unheld list_mutex in __w1_remove_master_device()
authorAlexey Khoroshilov <khoroshilov@ispras.ru>
Tue, 6 May 2014 21:26:04 +0000 (01:26 +0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 1 Jul 2014 03:13:53 +0000 (20:13 -0700)
commit a0f104644ec27ce5bbb36e950eb426dba9a3ad44 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/w1/w1.c
drivers/w1/w1_int.c

index ff52618cafbecab99224143424ad57887de789f1..5d7341520544f98727308c3f4f701c90129b1940 100644 (file)
@@ -1078,6 +1078,8 @@ static void w1_search_process(struct w1_master *dev, u8 search_type)
  * w1_process_callbacks() - execute each dev->async_list callback entry
  * @dev: w1_master device
  *
+ * The w1 master list_mutex must be held.
+ *
  * Return: 1 if there were commands to executed 0 otherwise
  */
 int w1_process_callbacks(struct w1_master *dev)
index 9b084db739c745b9940cd68ee268542f76820695..728039d2efe1e28c6cca5f8a2de57c2a42c639f7 100644 (file)
@@ -219,9 +219,13 @@ void __w1_remove_master_device(struct w1_master *dev)
 
                if (msleep_interruptible(1000))
                        flush_signals(current);
+               mutex_lock(&dev->list_mutex);
                w1_process_callbacks(dev);
+               mutex_unlock(&dev->list_mutex);
        }
+       mutex_lock(&dev->list_mutex);
        w1_process_callbacks(dev);
+       mutex_unlock(&dev->list_mutex);
 
        memset(&msg, 0, sizeof(msg));
        msg.id.mst.id = dev->id;