From: "Ryota OZAKI" Subject: [PATCH] kvm: user: Call pthread_join only to created threads. Date: Sat, 4 Oct 2008 16:20:30 +0900 Message-ID: <5e93dcec0810040020l18d97706m16d4b0669c5dffe4@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: "Ryota OZAKI" To: kvm@vger.kernel.org Return-path: Received: from wf-out-1314.google.com ([209.85.200.175]:41784 "EHLO wf-out-1314.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751613AbYJDHUb (ORCPT ); Sat, 4 Oct 2008 03:20:31 -0400 Received: by wf-out-1314.google.com with SMTP id 27so1969820wfd.4 for ; Sat, 04 Oct 2008 00:20:30 -0700 (PDT) Content-Disposition: inline Sender: kvm-owner@vger.kernel.org List-ID: Hi, This patch fixes a bug in kvmtrace. Thanks, ozaki-r >From 4ccee3a01c2e8c377dc6a760b5d7802e58afda72 Mon Sep 17 00:00:00 2001 From: Ryota Ozaki Date: Sat, 4 Oct 2008 15:30:48 +0900 Subject: [PATCH] kvm: user: Call pthread_join only to created threads. If thread_main fails with a somewhat reason (e.g. open fails) before all threads are created, pthread_join is called to a uncreated thread and a segmentation fault occurs. This patch checks whether a thread is created before calling pthread_join to the thread. Signed-off-by: Ryota Ozaki --- user/kvmtrace.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/user/kvmtrace.c b/user/kvmtrace.c index 876ac27..de3c189 100644 --- a/user/kvmtrace.c +++ b/user/kvmtrace.c @@ -454,7 +454,8 @@ static void stop_threads() int i; for_each_tip(tip, i) { - (void) pthread_join(tip->thread, (void *) &ret); + if (tip->thread) + (void) pthread_join(tip->thread, (void *) &ret); close_thread(tip); } } -- 1.5.4.1