diff options
author | Juergen Gross | 2020-03-05 11:03:23 +0100 |
---|---|---|
committer | Boris Ostrovsky | 2020-03-05 09:42:23 -0600 |
commit | 2f69a110e7bba3ec6bc089a2f736ca0941d887ed (patch) | |
tree | 57ffc62e0497d2f1be6ad89f9abd7c8adbdde722 /drivers/xen/xenbus/xenbus_probe_backend.c | |
parent | 8130b9d5b5abf26f9927b487c15319a187775f34 (diff) |
xen/xenbus: fix locking
Commit 060eabe8fbe726 ("xenbus/backend: Protect xenbus callback with
lock") introduced a bug by holding a lock while calling a function
which might schedule.
Fix that by using a semaphore instead.
Fixes: 060eabe8fbe726 ("xenbus/backend: Protect xenbus callback with lock")
Signed-off-by: Juergen Gross <jgross@suse.com>
Link: https://lore.kernel.org/r/20200305100323.16736-1-jgross@suse.com
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Diffstat (limited to 'drivers/xen/xenbus/xenbus_probe_backend.c')
-rw-r--r-- | drivers/xen/xenbus/xenbus_probe_backend.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/xen/xenbus/xenbus_probe_backend.c b/drivers/xen/xenbus/xenbus_probe_backend.c index 791f6fe01e91..9b2fbe69bccc 100644 --- a/drivers/xen/xenbus/xenbus_probe_backend.c +++ b/drivers/xen/xenbus/xenbus_probe_backend.c @@ -45,6 +45,7 @@ #include <linux/mm.h> #include <linux/notifier.h> #include <linux/export.h> +#include <linux/semaphore.h> #include <asm/page.h> #include <asm/pgtable.h> @@ -257,10 +258,10 @@ static int backend_reclaim_memory(struct device *dev, void *data) drv = to_xenbus_driver(dev->driver); if (drv && drv->reclaim_memory) { xdev = to_xenbus_device(dev); - if (!spin_trylock(&xdev->reclaim_lock)) + if (down_trylock(&xdev->reclaim_sem)) return 0; drv->reclaim_memory(xdev); - spin_unlock(&xdev->reclaim_lock); + up(&xdev->reclaim_sem); } return 0; } |