xen/pvcalls: fix potential endless loop in pvcalls-front.c
[sfrench/cifs-2.6.git] / drivers / xen / pvcalls-front.c
index 9e40c2cd70b1212cab0b307429f29611c592d372..40caa92bff33deaebf1bf01aac44571453660c0f 100644 (file)
@@ -1041,13 +1041,12 @@ int pvcalls_front_release(struct socket *sock)
                wake_up_interruptible(&map->active.inflight_conn_req);
 
                /*
-                * Wait until there are no more waiters on the mutexes.
-                * We know that no new waiters can be added because sk_send_head
-                * is set to NULL -- we only need to wait for the existing
-                * waiters to return.
+                * We need to make sure that sendmsg/recvmsg on this socket have
+                * not started before we've cleared sk_send_head here. The
+                * easiest (though not optimal) way to guarantee this is to see
+                * that no pvcall (other than us) is in progress.
                 */
-               while (!mutex_trylock(&map->active.in_mutex) ||
-                          !mutex_trylock(&map->active.out_mutex))
+               while (atomic_read(&pvcalls_refcount) > 1)
                        cpu_relax();
 
                pvcalls_front_free_map(bedata, map);