Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 340e01248478ba8b78a6d4d1809b1eff > files > 625

kvm-83-270.el5_11.src.rpm

From 3bba90f54db3b6cc3053f64d670e4c199bf333ee Mon Sep 17 00:00:00 2001
From: Avi Kivity <avi@redhat.com>
Date: Sun, 4 Mar 2012 12:54:39 +0100
Subject: [PATCH 3/3] posix-aio-compat: fix thread accounting leak

RH-Author: Avi Kivity <avi@redhat.com>
Message-id: <1330865679-18739-1-git-send-email-avi@redhat.com>
Patchwork-id: 37937
O-Subject: [PATCH qemu-kvm RHEL-5.9] posix-aio-compat: fix thread accounting leak
Bugzilla: 782631
RH-Acked-by: Gleb Natapov <gleb@redhat.com>
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>

Upstream: not vulnerable
Bugzilla: 782631

idle_threads is updated outside a lock, leading to a corrupted value.
This can cause the code to believe idle threads exist when in fact they
don't, so new threads are not spawned, and I/O stalls.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 qemu/posix-aio-compat.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Signed-off-by: Michal Novotny <minovotn@redhat.com>
---
 qemu/posix-aio-compat.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/qemu/posix-aio-compat.c b/qemu/posix-aio-compat.c
index aa3c71d..17d4d75 100644
--- a/qemu/posix-aio-compat.c
+++ b/qemu/posix-aio-compat.c
@@ -191,10 +191,10 @@ static void do_spawn_thread(void)
     new_threads--;
     pending_threads++;
 
-    mutex_unlock(&lock);
-
     idle_threads++;
 
+    mutex_unlock(&lock);
+
     ret = pthread_attr_init(&attr);
     if (ret) die2 (ret, "pthread_attr_init");
     ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-- 
1.7.7.6