diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2013-06-06 15:20:39 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-06-11 02:46:21 -0700 |
commit | 05c05351943cc03bf5c77e86953b24ae6fb21368 (patch) | |
tree | 51274c86eeca2cd5040979d1fdebd81fe0518a19 /drivers/vhost/vhost.c | |
parent | c2020be3c35ab230b4ee046c262ddab3e0d3aab4 (diff) |
vhost: check owner before we overwrite ubuf_info
If device has an owner, we shouldn't touch ubuf_info
since it might be in use.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/vhost/vhost.c')
-rw-r--r-- | drivers/vhost/vhost.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index beee7f5787e..60aa5ad09a2 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -344,13 +344,19 @@ static int vhost_attach_cgroups(struct vhost_dev *dev) } /* Caller should have device mutex */ +bool vhost_dev_has_owner(struct vhost_dev *dev) +{ + return dev->mm; +} + +/* Caller should have device mutex */ long vhost_dev_set_owner(struct vhost_dev *dev) { struct task_struct *worker; int err; /* Is there an owner already? */ - if (dev->mm) { + if (vhost_dev_has_owner(dev)) { err = -EBUSY; goto err_mm; } |