xen/xenbus: fix locking

[ Upstream commit 2f69a110e7bba3ec6bc089a2f736ca0941d887ed ]

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 <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Reviewed-by: Boris Ostrovsky <[email protected]>
Signed-off-by: Boris Ostrovsky <[email protected]>
Stable-dep-of: afc545da381b ("xen: Fix the issue of resource not being properly released in xenbus_dev_probe()")
Signed-off-by: Sasha Levin <[email protected]>
This commit is contained in:
Juergen Gross 2020-03-05 11:03:23 +01:00 • committed by Greg Kroah-Hartman
commit 1c264dd643
3 changed files with 10 additions and 8 deletions

View file

@ -42,6 +42,7 @@
#include <linux/completion.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/semaphore.h>
#include <xen/interface/xen.h>
#include <xen/interface/grant_table.h>
#include <xen/interface/io/xenbus.h>
@ -85,7 +86,7 @@ struct xenbus_device {
enum xenbus_state state;
struct completion down;
struct work_struct work;
spinlock_t reclaim_lock;
struct semaphore reclaim_sem;
};
static inline struct xenbus_device *to_xenbus_device(struct device *dev)