xen/pvcalls: fix potential endless loop in pvcalls-front.c
authorStefano Stabellini <sstabellini@kernel.org>
Wed, 15 Nov 2017 21:20:21 +0000 (13:20 -0800)
committerBoris Ostrovsky <boris.ostrovsky@oracle.com>
Wed, 15 Nov 2017 21:38:15 +0000 (16:38 -0500)
commit646d944c2ef5a3b298c4e150494c71b9272d8b47
tree7dc5ca8c8681c80b438db0babfebe26e2f1ecbc0
parent24e7f84db0db6b6f14581707a45d06ec5d5b88f2
xen/pvcalls: fix potential endless loop in pvcalls-front.c

mutex_trylock() returns 1 if you take the lock and 0 if not. Assume you
take in_mutex on the first try, but you can't take out_mutex. Next times
you call mutex_trylock() in_mutex is going to fail. It's an endless
loop.

Solve the problem by waiting until the global refcount is 1 instead (the
refcount is 1 when the only active pvcalls frontend function is
pvcalls_front_release).

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
drivers/xen/pvcalls-front.c