From nobody Fri Nov 7 15:31:10 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1548259249490743.6002170902215; Wed, 23 Jan 2019 08:00:49 -0800 (PST) Received: from localhost ([127.0.0.1]:37312 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gmKxM-0008Ml-E4 for importer@patchew.org; Wed, 23 Jan 2019 11:00:48 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40889) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gmKvM-0006tv-I0 for qemu-devel@nongnu.org; Wed, 23 Jan 2019 10:58:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gmKvL-0005Rj-Bx for qemu-devel@nongnu.org; Wed, 23 Jan 2019 10:58:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59494) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gmKvL-0005QY-1X for qemu-devel@nongnu.org; Wed, 23 Jan 2019 10:58:43 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2F22658E23; Wed, 23 Jan 2019 15:58:42 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-117-254.ams2.redhat.com [10.36.117.254]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9A29B67140; Wed, 23 Jan 2019 15:58:40 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org Date: Wed, 23 Jan 2019 15:58:22 +0000 Message-Id: <20190123155830.8459-2-dgilbert@redhat.com> In-Reply-To: <20190123155830.8459-1-dgilbert@redhat.com> References: <20190123155830.8459-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 23 Jan 2019 15:58:42 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/9] Fix segmentation fault when qemu_signal_init fails 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: , Cc: quintela@redhat.com, lifei1214@126.com, xiaoguangrong@tencent.com, peterx@redhat.com, shirley17fei@gmail.com, marcandre.lureau@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Fei Li When qemu_signal_init() fails in qemu_init_main_loop(), we return without setting an error. Its callers crash then when they try to report the error with error_report_err(). To avoid such segmentation fault, add a new Error parameter to make the call trace to propagate the err to the final caller. Fixes: 2f78e491d7b46542158ce0b8132ee4e05bc0ade4 Cc: Paolo Bonzini Signed-off-by: Fei Li Reviewed-by: Fam Zheng Reviewed-by: Markus Armbruster Message-Id: <20190113140849.38339-2-lifei1214@126.com> Signed-off-by: Dr. David Alan Gilbert --- util/main-loop.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/util/main-loop.c b/util/main-loop.c index affe0403c5..443cb4cfe8 100644 --- a/util/main-loop.c +++ b/util/main-loop.c @@ -71,7 +71,7 @@ static void sigfd_handler(void *opaque) } } =20 -static int qemu_signal_init(void) +static int qemu_signal_init(Error **errp) { int sigfd; sigset_t set; @@ -96,7 +96,7 @@ static int qemu_signal_init(void) sigdelset(&set, SIG_IPI); sigfd =3D qemu_signalfd(&set); if (sigfd =3D=3D -1) { - fprintf(stderr, "failed to create signalfd\n"); + error_setg_errno(errp, errno, "failed to create signalfd"); return -errno; } =20 @@ -109,7 +109,7 @@ static int qemu_signal_init(void) =20 #else /* _WIN32 */ =20 -static int qemu_signal_init(void) +static int qemu_signal_init(Error **errp) { return 0; } @@ -148,7 +148,7 @@ int qemu_init_main_loop(Error **errp) =20 init_clocks(qemu_timer_notify_cb); =20 - ret =3D qemu_signal_init(); + ret =3D qemu_signal_init(errp); if (ret) { return ret; } --=20 2.20.1