All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ryota OZAKI" <ozaki.ryota@gmail.com>
To: kvm@vger.kernel.org
Cc: "Ryota OZAKI" <ozaki.ryota@gmail.com>
Subject: [PATCH] kvm: user: Call pthread_join only to created threads.
Date: Sat, 4 Oct 2008 16:20:30 +0900	[thread overview]
Message-ID: <5e93dcec0810040020l18d97706m16d4b0669c5dffe4@mail.gmail.com> (raw)

Hi,

This patch fixes a bug in kvmtrace.

Thanks,
  ozaki-r

>From 4ccee3a01c2e8c377dc6a760b5d7802e58afda72 Mon Sep 17 00:00:00 2001
From: Ryota Ozaki <ozaki.ryota@gmail.com>
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 <ozaki.ryota@gmail.com>
---
 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

             reply	other threads:[~2008-10-04  7:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-04  7:20 Ryota OZAKI [this message]
2008-10-05 10:00 ` [PATCH] kvm: user: Call pthread_join only to created threads Avi Kivity

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=5e93dcec0810040020l18d97706m16d4b0669c5dffe4@mail.gmail.com \
    --to=ozaki.ryota@gmail.com \
    --cc=kvm@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.