From: Stefano Stabellini <sstabellini@kernel.org>
To: xen-devel@lists.xenproject.org
Cc: jgross@suse.com, boris.ostrovsky@oracle.com, sstabellini@kernel.org
Subject: [PATCH] xen/pvcalls: fix potential endless loop in pvcalls-front.c
Date: Mon, 6 Nov 2017 14:17:59 -0800 [thread overview]
Message-ID: <1510006679-6381-1-git-send-email-sstabellini@kernel.org> (raw)
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 moving the two mutex_trylock calls to two separate
loops.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
CC: boris.ostrovsky@oracle.com
CC: jgross@suse.com
---
drivers/xen/pvcalls-front.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/xen/pvcalls-front.c b/drivers/xen/pvcalls-front.c
index 0c1ec68..047dce7 100644
--- a/drivers/xen/pvcalls-front.c
+++ b/drivers/xen/pvcalls-front.c
@@ -1048,8 +1048,9 @@ int pvcalls_front_release(struct socket *sock)
* is set to NULL -- we only need to wait for the existing
* waiters to return.
*/
- while (!mutex_trylock(&map->active.in_mutex) ||
- !mutex_trylock(&map->active.out_mutex))
+ while (!mutex_trylock(&map->active.in_mutex))
+ cpu_relax();
+ while (!mutex_trylock(&map->active.out_mutex))
cpu_relax();
pvcalls_front_free_map(bedata, map);
--
1.9.1
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next reply other threads:[~2017-11-06 22:18 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-06 22:17 Stefano Stabellini [this message]
2017-11-06 22:34 ` [PATCH] xen/pvcalls: fix potential endless loop in pvcalls-front.c Boris Ostrovsky
2017-11-06 22:38 ` Stefano Stabellini
2017-11-07 5:44 ` Juergen Gross
2017-11-10 23:57 ` Stefano Stabellini
2017-11-11 2:02 ` Boris Ostrovsky
2017-11-13 18:30 ` Stefano Stabellini
2017-11-13 15:15 ` Juergen Gross
2017-11-13 18:33 ` Stefano Stabellini
2017-11-14 9:11 ` Juergen Gross
2017-11-14 21:46 ` Boris Ostrovsky
2017-11-15 8:14 ` Juergen Gross
2017-11-15 19:09 ` Stefano Stabellini
2017-11-15 19:50 ` Boris Ostrovsky
2017-11-15 19:53 ` Boris Ostrovsky
2017-11-15 21:20 ` Stefano Stabellini
2017-11-15 21:50 ` Stefano Stabellini
2017-11-15 21:51 ` Boris Ostrovsky
2017-11-15 21:54 ` Stefano Stabellini
2017-11-16 5:28 ` Juergen Gross
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1510006679-6381-1-git-send-email-sstabellini@kernel.org \
--to=sstabellini@kernel.org \
--cc=boris.ostrovsky@oracle.com \
--cc=jgross@suse.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).