vhost: put mm after thread stop
authorMichael S. Tsirkin <mst@redhat.com>
Wed, 6 Oct 2010 13:34:38 +0000 (15:34 +0200)
committerMichael S. Tsirkin <mst@redhat.com>
Thu, 4 Nov 2010 11:22:10 +0000 (13:22 +0200)
makes it possible to batch use/unuse mm

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/vhost/vhost.c

index ed27727..9920bae 100644 (file)
@@ -401,15 +401,14 @@ void vhost_dev_cleanup(struct vhost_dev *dev)
        kfree(rcu_dereference_protected(dev->memory,
                                        lockdep_is_held(&dev->mutex)));
        RCU_INIT_POINTER(dev->memory, NULL);
-       if (dev->mm)
-               mmput(dev->mm);
-       dev->mm = NULL;
-
        WARN_ON(!list_empty(&dev->work_list));
        if (dev->worker) {
                kthread_stop(dev->worker);
                dev->worker = NULL;
        }
+       if (dev->mm)
+               mmput(dev->mm);
+       dev->mm = NULL;
 }
 
 static int log_access_ok(void __user *log_base, u64 addr, unsigned long sz)