From nobody Mon Feb 9 02:28:45 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1543485962158960.1590570107776; Thu, 29 Nov 2018 02:06:02 -0800 (PST) Received: from localhost ([::1]:53153 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSJCq-00065x-Gc for importer@patchew.org; Thu, 29 Nov 2018 05:06:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43625) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSJB4-0005AP-7E for qemu-devel@nongnu.org; Thu, 29 Nov 2018 05:04:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gSJB2-0004If-PB for qemu-devel@nongnu.org; Thu, 29 Nov 2018 05:04:10 -0500 Received: from smtp.nue.novell.com ([195.135.221.5]:49299) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gSJB2-0004Hl-Ej for qemu-devel@nongnu.org; Thu, 29 Nov 2018 05:04:08 -0500 Received: from localhost.localdomain ([45.122.156.254]) by smtp.nue.novell.com with ESMTP (NOT encrypted); Thu, 29 Nov 2018 11:04:05 +0100 From: Fei Li To: qemu-devel@nongnu.org Date: Thu, 29 Nov 2018 18:03:37 +0800 Message-Id: <20181129100340.13823-3-fli@suse.com> X-Mailer: git-send-email 2.13.7 In-Reply-To: <20181129100340.13823-1-fli@suse.com> References: <20181129100340.13823-1-fli@suse.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 195.135.221.5 Subject: [Qemu-devel] [PATCH RFC v2 2/5] qemu_thread_join: fix segmentation fault X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" To avoid the segmentation fault in qemu_thread_join(), just directly return when the QemuThread *thread failed to be created in either qemu-thread-posix.c or qemu-thread-win32.c. Signed-off-by: Fei Li Reviewed-by: Fam Zheng --- util/qemu-thread-posix.c | 3 +++ util/qemu-thread-win32.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c index 865e476df5..b9ab5a4711 100644 --- a/util/qemu-thread-posix.c +++ b/util/qemu-thread-posix.c @@ -558,6 +558,9 @@ void *qemu_thread_join(QemuThread *thread) int err; void *ret; =20 + if (!thread->thread) { + return NULL; + } err =3D pthread_join(thread->thread, &ret); if (err) { error_exit(err, __func__); diff --git a/util/qemu-thread-win32.c b/util/qemu-thread-win32.c index 4a363ca675..1a27e1cf6f 100644 --- a/util/qemu-thread-win32.c +++ b/util/qemu-thread-win32.c @@ -366,7 +366,7 @@ void *qemu_thread_join(QemuThread *thread) HANDLE handle; =20 data =3D thread->data; - if (data->mode =3D=3D QEMU_THREAD_DETACHED) { + if (data =3D=3D NULL || data->mode =3D=3D QEMU_THREAD_DETACHED) { return NULL; } =20 --=20 2.13.7