From patchwork Sat Nov 30 19:42:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 11268105 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 450D9109A for ; Sat, 30 Nov 2019 19:50:59 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 174C42073C for ; Sat, 30 Nov 2019 19:50:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PusjTVad" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 174C42073C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37720 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8ld-0007lL-3j for patchwork-qemu-devel@patchwork.kernel.org; Sat, 30 Nov 2019 14:50:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53529) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8ds-0006Tk-Qx for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:42:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ib8dq-00058y-S1 for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:42:56 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:50963 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ib8do-00055M-R1 for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:42:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575142971; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QqX1QH5afYUXC10/rVNgiR/DuTiOhSvgW/1+jEyMUHQ=; b=PusjTVadOOL0gYMTMQTwaBTkp9riFIDJDgmNj+yPLQDcTSmWnxlsi6IAI59wQA78aDIhoI xLsmUF/Fela5AQuuvLG7S4FLk1OEbKNDf9zfK78hPKMUKR8JW980xki8UJn5y5XrgRTL/u YEUkof/kt3lxebig+gj4y8CdK7z7Ll8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-241-EOCCzsdjN-WplvAgIhdMUg-1; Sat, 30 Nov 2019 14:42:49 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DB7EE800D41; Sat, 30 Nov 2019 19:42:48 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-134.ams2.redhat.com [10.36.116.134]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7145B19C5B; Sat, 30 Nov 2019 19:42:43 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 082C811385C7; Sat, 30 Nov 2019 20:42:41 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 01/21] net/virtio: Drop useless n->primary_dev not null checks Date: Sat, 30 Nov 2019 20:42:20 +0100 Message-Id: <20191130194240.10517-2-armbru@redhat.com> In-Reply-To: <20191130194240.10517-1-armbru@redhat.com> References: <20191130194240.10517-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: EOCCzsdjN-WplvAgIhdMUg-1 X-Mimecast-Spam-Score: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: vsementsov@virtuozzo.com, Jens Freimann , "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" virtio_net_handle_migration_primary() returns early when it can't ensure n->primary_dev is non-null. Checking it again right after that early return is redundant. Drop. If n->primary_dev is null on entering failover_replug_primary(), @pdev will become null, and pdev->partially_hotplugged will crash. Checking n->primary_dev later is useless. It can't actually be null, because its caller virtio_net_handle_migration_primary() ensures it isn't. Drop the useless check. Cc: Jens Freimann Cc: Michael S. Tsirkin Signed-off-by: Markus Armbruster Reviewed-by: Jens Freimann --- hw/net/virtio-net.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 3c31471026..87088ba374 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -2810,11 +2810,6 @@ static bool failover_replug_primary(VirtIONet *n, Error **errp) goto out; } } - if (!n->primary_dev) { - error_setg(errp, "virtio_net: couldn't find primary device"); - goto out; - } - n->primary_bus = n->primary_dev->parent_bus; if (!n->primary_bus) { error_setg(errp, "virtio_net: couldn't find primary bus"); @@ -2849,8 +2844,7 @@ static void virtio_net_handle_migration_primary(VirtIONet *n, } } - if (migration_in_setup(s) && !should_be_hidden && - n->primary_dev) { + if (migration_in_setup(s) && !should_be_hidden) { if (failover_unplug_primary(n)) { vmstate_unregister(n->primary_dev, qdev_get_vmsd(n->primary_dev), n->primary_dev); From patchwork Sat Nov 30 19:42:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 11268083 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 38F46109A for ; Sat, 30 Nov 2019 19:44:37 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0EAFF2084E for ; Sat, 30 Nov 2019 19:44:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="OTqWS+sE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0EAFF2084E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37638 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8fT-0008Fa-Pe for patchwork-qemu-devel@patchwork.kernel.org; Sat, 30 Nov 2019 14:44:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53530) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8ds-0006Tl-RB for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:42:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ib8dq-000595-SK for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:42:56 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:48547 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ib8do-000554-R3 for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:42:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575142971; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fiBMWv3b4dYJ2SZifg0hNYS4tAtr7MwqgE6vP+ma9M0=; b=OTqWS+sEt3BwwOwUL5rWIB+g4J0pgOGWMJOSaQw+jvi73PTh7QNVsoteIREG7CJIOQKyzw fgvVLRzDca3wkYid/BIZvBq/cICe5aKG4gGJKk56mUu1+N4KY4/geNoFrLt2qYfWFNpf0z 052w95tAD5H6DJ7LH9t3rjGy9qwSC6k= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-98-itZyFkEUPZ2YQnrYZa-nvQ-1; Sat, 30 Nov 2019 14:42:49 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EA4D7DB20; Sat, 30 Nov 2019 19:42:48 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-134.ams2.redhat.com [10.36.116.134]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 712AC1001281; Sat, 30 Nov 2019 19:42:43 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 0BC5811366CC; Sat, 30 Nov 2019 20:42:41 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 02/21] net/virtio: Fix failover error handling crash bugs Date: Sat, 30 Nov 2019 20:42:21 +0100 Message-Id: <20191130194240.10517-3-armbru@redhat.com> In-Reply-To: <20191130194240.10517-1-armbru@redhat.com> References: <20191130194240.10517-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: itZyFkEUPZ2YQnrYZa-nvQ-1 X-Mimecast-Spam-Score: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: vsementsov@virtuozzo.com, Jens Freimann , "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Functions that take an Error ** parameter to pass an error to the caller expect the parameter to point to null. failover_replug_primary() violates this precondition in several places: * After qemu_opts_from_qdict() failed, *errp is no longer null. Passing it to error_setg() is wrong, and will trip the assertion in error_setv(). Messed up in commit 150ab54aa6 "net/virtio: fix re-plugging of primary device". Simply drop the error_setg(). * Passing @errp to qemu_opt_set_bool(), hotplug_handler_pre_plug(), and hotplug_handler_plug() is wrong. If one of the first two fails, *errp is no longer null. Risks tripping the same assertion. Moreover, continuing after such errors is unsafe. Messed up in commit 9711cd0dfc "net/virtio: add failover support". Fix by handling each error properly. failover_replug_primary() crashes when passed a null @errp. Also messed up in commit 9711cd0dfc. This bug can't bite as no caller actually passes null. Fix it anyway. Fixes: 9711cd0dfc3fa414f7f64935713c07134ae67971 Fixes: 150ab54aa6934583180f88a2bd540bc6fc4fbff3 Cc: Jens Freimann Cc: Michael S. Tsirkin Signed-off-by: Markus Armbruster Reviewed-by: Jens Freimann --- hw/net/virtio-net.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 87088ba374..db3d7c38e6 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -2795,6 +2795,7 @@ static bool failover_unplug_primary(VirtIONet *n) static bool failover_replug_primary(VirtIONet *n, Error **errp) { + Error *err = NULL; HotplugHandler *hotplug_ctrl; PCIDevice *pdev = PCI_DEVICE(n->primary_dev); @@ -2806,27 +2807,33 @@ static bool failover_replug_primary(VirtIONet *n, Error **errp) qemu_find_opts("device"), n->primary_device_dict, errp); if (!n->primary_device_opts) { - error_setg(errp, "virtio_net: couldn't find primary device opts"); - goto out; + return false; } } n->primary_bus = n->primary_dev->parent_bus; if (!n->primary_bus) { error_setg(errp, "virtio_net: couldn't find primary bus"); - goto out; + return false; } qdev_set_parent_bus(n->primary_dev, n->primary_bus); n->primary_should_be_hidden = false; qemu_opt_set_bool(n->primary_device_opts, - "partially_hotplugged", true, errp); + "partially_hotplugged", true, &err); + if (err) { + goto out; + } hotplug_ctrl = qdev_get_hotplug_handler(n->primary_dev); if (hotplug_ctrl) { - hotplug_handler_pre_plug(hotplug_ctrl, n->primary_dev, errp); + hotplug_handler_pre_plug(hotplug_ctrl, n->primary_dev, &err); + if (err) { + goto out; + } hotplug_handler_plug(hotplug_ctrl, n->primary_dev, errp); } out: - return *errp == NULL; + error_propagate(errp, err); + return !err; } static void virtio_net_handle_migration_primary(VirtIONet *n, From patchwork Sat Nov 30 19:42:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 11268081 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 936E017F0 for ; Sat, 30 Nov 2019 19:44:31 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6A3D42084E for ; Sat, 30 Nov 2019 19:44:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="E/V4oXZI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6A3D42084E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37636 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8fN-00086i-UK for patchwork-qemu-devel@patchwork.kernel.org; Sat, 30 Nov 2019 14:44:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53466) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8dq-0006Qc-Al for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:42:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ib8dm-000549-Ss for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:42:52 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:46272 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ib8dm-00052v-0J for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:42:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575142968; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vJaBWRixGViWAeulqiB62tyEcddZ3xek8SJVT6ZMmAA=; b=E/V4oXZIJAStWonGOKL12rASRYYsc2sa3+7LDBjkk1CNssCZIZggEE9GF/NRlmAW8qQv3n x/b6YTJBmmi9ft+40pKvSfqWgRwNKQKh2chjz9f6BdlVdCto8ucWG5bndLdOG6biHYqWVf eBocCHtzQr8l1BWxedpjZAAu3OniQDQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-80-i1wNotwBOZ2_OPgq2EG6jw-1; Sat, 30 Nov 2019 14:42:47 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4F4C7800D41; Sat, 30 Nov 2019 19:42:46 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-134.ams2.redhat.com [10.36.116.134]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 59051611DB; Sat, 30 Nov 2019 19:42:43 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 1134B11366CF; Sat, 30 Nov 2019 20:42:41 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 03/21] block/file-posix: Fix laio_init() error handling crash bug Date: Sat, 30 Nov 2019 20:42:22 +0100 Message-Id: <20191130194240.10517-4-armbru@redhat.com> In-Reply-To: <20191130194240.10517-1-armbru@redhat.com> References: <20191130194240.10517-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: i1wNotwBOZ2_OPgq2EG6jw-1 X-Mimecast-Spam-Score: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , vsementsov@virtuozzo.com, Nishanth Aravamudan , Stefan Hajnoczi Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" raw_aio_attach_aio_context() passes uninitialized Error *local_err by reference to laio_init() via aio_setup_linux_aio(). When laio_init() fails, it passes it on to error_setg_errno(), tripping error_setv()'s assertion unless @local_err is null by dumb luck. Fix by initializing @local_err properly. Fixes: ed6e2161715c527330f936d44af4c547f25f687e Cc: Nishanth Aravamudan Cc: Stefan Hajnoczi Cc: Kevin Wolf Signed-off-by: Markus Armbruster Reviewed-by: Stefan Hajnoczi Reviewed-by: Kevin Wolf --- block/file-posix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/file-posix.c b/block/file-posix.c index 1f0f61a02b..1b805bd938 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -1973,7 +1973,7 @@ static void raw_aio_attach_aio_context(BlockDriverState *bs, #ifdef CONFIG_LINUX_AIO BDRVRawState *s = bs->opaque; if (s->use_linux_aio) { - Error *local_err; + Error *local_err = NULL; if (!aio_setup_linux_aio(new_context, &local_err)) { error_reportf_err(local_err, "Unable to use native AIO, " "falling back to thread pool: "); From patchwork Sat Nov 30 19:42:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 11268079 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D99B5109A for ; Sat, 30 Nov 2019 19:44:30 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AF4F42084E for ; Sat, 30 Nov 2019 19:44:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PRCu9a10" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AF4F42084E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37634 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8fN-00085G-AB for patchwork-qemu-devel@patchwork.kernel.org; Sat, 30 Nov 2019 14:44:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53467) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8dq-0006Qd-At for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:42:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ib8dm-000543-SE for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:42:52 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:40585 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ib8dl-000531-US for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:42:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575142968; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=E4N9e38HWdd95QkHzCa+MZyOQk8kGL3rr8n3UF0VKIQ=; b=PRCu9a10VKpLEXI7oP6nfig8Q4I9AY+ZZef/WGxnSSmTV/kRfEyA/XdeNIXG/9GEP5DrnJ gpz/f3dc8vJYycv4+qSn0yUyRWsRausD76bph6W2Xx8JhYNDoac5eNeOKsm0h0tiI/+IUO xciWDM/BKWv+LTeS/5zSRrrjOxEAeEE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-428-AngOt7hSMNiyZx1pES8rMQ-1; Sat, 30 Nov 2019 14:42:47 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 45E7F80183C; Sat, 30 Nov 2019 19:42:46 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-134.ams2.redhat.com [10.36.116.134]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 713FF19C58; Sat, 30 Nov 2019 19:42:43 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 11E5511366D1; Sat, 30 Nov 2019 20:42:41 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 04/21] crypto: Fix certificate file error handling crash bug Date: Sat, 30 Nov 2019 20:42:23 +0100 Message-Id: <20191130194240.10517-5-armbru@redhat.com> In-Reply-To: <20191130194240.10517-1-armbru@redhat.com> References: <20191130194240.10517-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: AngOt7hSMNiyZx1pES8rMQ-1 X-Mimecast-Spam-Score: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: vsementsov@virtuozzo.com, =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" qcrypto_tls_creds_load_cert() passes uninitialized GError *gerr by reference to g_file_get_contents(). When g_file_get_contents() fails, it'll try to set a GError. Unless @gerr is null by dumb luck, this logs a ERROR_OVERWRITTEN_WARNING warning message and leaves @gerr unchanged. qcrypto_tls_creds_load_cert() then dereferences the uninitialized @gerr. Fix by initializing @gerr properly. Fixes: 9a2fd4347c40321f5cbb4ab4220e759fcbf87d03 Cc: "Daniel P. Berrangé" Signed-off-by: Markus Armbruster Reviewed-by: Vladimir Sementsov-Ogievskiy --- crypto/tlscredsx509.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/tlscredsx509.c b/crypto/tlscredsx509.c index 01fc304e5d..53a4368f49 100644 --- a/crypto/tlscredsx509.c +++ b/crypto/tlscredsx509.c @@ -380,7 +380,7 @@ qcrypto_tls_creds_load_cert(QCryptoTLSCredsX509 *creds, gnutls_x509_crt_t cert = NULL; g_autofree char *buf = NULL; gsize buflen; - GError *gerr; + GError *gerr = NULL; int ret = -1; int err; From patchwork Sat Nov 30 19:42:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 11268089 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DDCCA109A for ; Sat, 30 Nov 2019 19:47:50 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B4AC42073C for ; Sat, 30 Nov 2019 19:47:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="MtCS2dxH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B4AC42073C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37680 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8ib-00047E-3k for patchwork-qemu-devel@patchwork.kernel.org; Sat, 30 Nov 2019 14:47:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53486) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8dq-0006T6-Qy for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:42:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ib8dm-00054Y-Vg for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:42:54 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:55331 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ib8dm-00053N-Rx for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:42:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575142969; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=z5LJs4qmj5nbhlefhQkW8UndCpDHWlAMIMigpcb7EAg=; b=MtCS2dxHRwpZo7dn0gJppp5jMk+wOhGRNLy3MaiCAYOl7zd4MPKBBUJpWLw6788k8fX5Jp LtttsJV7sTkpePtO66sHdinnMd5xuN7iSU9myMYOqvxq81s2lV/oiFrPGFJvrQ9o34EODb pNE3nbuGUpuBkeeWgOHMxFQk6laPaQE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-268-Vk1-qVv0NVKLpLhdgli6vQ-1; Sat, 30 Nov 2019 14:42:48 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B1FF0184CABB; Sat, 30 Nov 2019 19:42:47 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-134.ams2.redhat.com [10.36.116.134]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 81CDD1001938; Sat, 30 Nov 2019 19:42:47 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 15F8B11366D5; Sat, 30 Nov 2019 20:42:41 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 05/21] crypto: Fix typo in QCryptoTLSSession's comment Date: Sat, 30 Nov 2019 20:42:24 +0100 Message-Id: <20191130194240.10517-6-armbru@redhat.com> In-Reply-To: <20191130194240.10517-1-armbru@redhat.com> References: <20191130194240.10517-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: Vk1-qVv0NVKLpLhdgli6vQ-1 X-Mimecast-Spam-Score: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: vsementsov@virtuozzo.com, =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Cc: "Daniel P. Berrangé" Signed-off-by: Markus Armbruster Reviewed-by: Vladimir Sementsov-Ogievskiy --- include/crypto/tlssession.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/crypto/tlssession.h b/include/crypto/tlssession.h index e01e1a9dc2..15b9cef086 100644 --- a/include/crypto/tlssession.h +++ b/include/crypto/tlssession.h @@ -56,7 +56,7 @@ * * static int mysock_run_tls(int sockfd, * QCryptoTLSCreds *creds, - * Error *errp) + * Error **errp) * { * QCryptoTLSSession *sess; * From patchwork Sat Nov 30 19:42:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 11268133 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8A233139A for ; Sat, 30 Nov 2019 19:58:16 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 610FB20732 for ; Sat, 30 Nov 2019 19:58:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="f/3QvFNp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 610FB20732 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37804 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8sh-0008Ne-72 for patchwork-qemu-devel@patchwork.kernel.org; Sat, 30 Nov 2019 14:58:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53531) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8ds-0006Tn-Qu for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:43:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ib8dq-00059D-SW for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:42:56 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:49679 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ib8do-00055R-RR for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:42:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575142972; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dc9Zi859fZ/6PNfDggKzxG0kjve40PrhKYv1nIJAHo0=; b=f/3QvFNp0KwEb8biJJ3ToPU0HjUgPAHaki9xt9M/+pO5fpUjTZ8I0iO2Gje9p00uFIXach t+LKBKjgL1ZWB8xSUPtBtqYm7ye8BE3WLUCkbCKa9tDFJgnL5nQTU959NdW4KBMZ6h4c/q ckl5Vycn9f8DATPpi80IAL32h5rXbnU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-232-sNA1v2rQPBq7gX7qOtKxUA-1; Sat, 30 Nov 2019 14:42:48 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B6A6B184CABC; Sat, 30 Nov 2019 19:42:47 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-134.ams2.redhat.com [10.36.116.134]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 84BD319C58; Sat, 30 Nov 2019 19:42:47 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 1951011366DB; Sat, 30 Nov 2019 20:42:41 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 06/21] io: Fix Error usage in a comment Date: Sat, 30 Nov 2019 20:42:25 +0100 Message-Id: <20191130194240.10517-7-armbru@redhat.com> In-Reply-To: <20191130194240.10517-1-armbru@redhat.com> References: <20191130194240.10517-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: sNA1v2rQPBq7gX7qOtKxUA-1 X-Mimecast-Spam-Score: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: vsementsov@virtuozzo.com, =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Cc: "Daniel P. Berrangé" Signed-off-by: Markus Armbruster Reviewed-by: Vladimir Sementsov-Ogievskiy --- include/io/task.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/io/task.h b/include/io/task.h index 5cb9faf9f2..1abbfb8b65 100644 --- a/include/io/task.h +++ b/include/io/task.h @@ -119,7 +119,7 @@ typedef void (*QIOTaskWorker)(QIOTask *task, * gboolean myobject_operation_timer(gpointer opaque) * { * QIOTask *task = QIO_TASK(opaque); - * Error *err;* + * Error *err = NULL; * * ...check something important... * if (err) { From patchwork Sat Nov 30 19:42:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 11268087 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5CFE4109A for ; Sat, 30 Nov 2019 19:47:44 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3282D2073C for ; Sat, 30 Nov 2019 19:47:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ISXPvnlo" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3282D2073C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37678 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8iU-0003qq-0J for patchwork-qemu-devel@patchwork.kernel.org; Sat, 30 Nov 2019 14:47:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53528) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8ds-0006Th-Ql for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:43:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ib8dq-00058h-Pi for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:42:56 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:59410 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ib8do-00055W-Qi for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:42:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575142972; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KAnozijQnJ7jZgrp+o4jADOZ48ZvoJvjxYWiOwhxZ0o=; b=ISXPvnloOKBjC9rFPB2U2jeYnXhECgCo46BCZ7kaGV3XOvJSYebU451MBEtdTzVpFpJXvO 3QtKgMsKughv/lBz4dz8uUtyv2x7JCP2hgFYwfiImuBgGpGHm1YeG2/XANzoVcwtJZz9R+ TdhEBfXtsmjzTk585RCsrHfgyqWcSfU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-172-n9TnEU-QOACEPD7fGMN2dQ-1; Sat, 30 Nov 2019 14:42:48 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B44D2DB21; Sat, 30 Nov 2019 19:42:47 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-134.ams2.redhat.com [10.36.116.134]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 875F9600C1; Sat, 30 Nov 2019 19:42:47 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 1C9EF11366DF; Sat, 30 Nov 2019 20:42:41 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 07/21] tests: Clean up initialization of Error *err variables Date: Sat, 30 Nov 2019 20:42:26 +0100 Message-Id: <20191130194240.10517-8-armbru@redhat.com> In-Reply-To: <20191130194240.10517-1-armbru@redhat.com> References: <20191130194240.10517-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: n9TnEU-QOACEPD7fGMN2dQ-1 X-Mimecast-Spam-Score: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: vsementsov@virtuozzo.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Declaring a local Error *err without initializer looks suspicious. Fuse the declaration with the initialization to avoid that. Signed-off-by: Markus Armbruster Reviewed-by: Vladimir Sementsov-Ogievskiy --- tests/test-qobject-output-visitor.c | 8 ++++---- tests/test-string-output-visitor.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test-qobject-output-visitor.c b/tests/test-qobject-output-visitor.c index 3e993e5ba8..d7761ebf84 100644 --- a/tests/test-qobject-output-visitor.c +++ b/tests/test-qobject-output-visitor.c @@ -145,10 +145,10 @@ static void test_visitor_out_enum_errors(TestOutputVisitorData *data, const void *unused) { EnumOne i, bad_values[] = { ENUM_ONE__MAX, -1 }; - Error *err; for (i = 0; i < ARRAY_SIZE(bad_values) ; i++) { - err = NULL; + Error *err = NULL; + visit_type_EnumOne(data->ov, "unused", &bad_values[i], &err); error_free_or_abort(&err); visitor_reset(data); @@ -240,11 +240,11 @@ static void test_visitor_out_struct_errors(TestOutputVisitorData *data, EnumOne bad_values[] = { ENUM_ONE__MAX, -1 }; UserDefOne u = {0}; UserDefOne *pu = &u; - Error *err; int i; for (i = 0; i < ARRAY_SIZE(bad_values) ; i++) { - err = NULL; + Error *err = NULL; + u.has_enum1 = true; u.enum1 = bad_values[i]; visit_type_UserDefOne(data->ov, "unused", &pu, &err); diff --git a/tests/test-string-output-visitor.c b/tests/test-string-output-visitor.c index 02766c0f65..1be1540767 100644 --- a/tests/test-string-output-visitor.c +++ b/tests/test-string-output-visitor.c @@ -207,10 +207,10 @@ static void test_visitor_out_enum_errors(TestOutputVisitorData *data, const void *unused) { EnumOne i, bad_values[] = { ENUM_ONE__MAX, -1 }; - Error *err; for (i = 0; i < ARRAY_SIZE(bad_values) ; i++) { - err = NULL; + Error *err = NULL; + visit_type_EnumOne(data->ov, "unused", &bad_values[i], &err); error_free_or_abort(&err); } From patchwork Sat Nov 30 19:42:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 11268123 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CA741109A for ; Sat, 30 Nov 2019 19:53:57 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A1D0220732 for ; Sat, 30 Nov 2019 19:53:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="i8x+bWHk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A1D0220732 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37746 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8oW-00032x-LA for patchwork-qemu-devel@patchwork.kernel.org; Sat, 30 Nov 2019 14:53:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53527) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8ds-0006Tg-Qh for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:43:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ib8dq-000593-Rj for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:42:56 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:44727 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ib8do-00055U-RT for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:42:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575142972; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ui6GrgoIca+XbfoMtNNhuIbZOCAX//qMjn54wOZVwE0=; b=i8x+bWHk/bEay8rChZ+/Wcnz78mjLGl55F1Cl9DigIi/wcVZfLbFVuynjUexWw4GSqd09p dbbvOSNbh/oDseodB24HxVamc4sFO/UtPWNBZOyXciLnsJFwn7TTINE+bvELuMFkwm3VLs MV4gyUO76PQU0QfoVx9luLhCh61+UnU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-263-rIGtdbenONej9jLdE2_7DA-1; Sat, 30 Nov 2019 14:42:48 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B9A63107ACC4; Sat, 30 Nov 2019 19:42:47 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-134.ams2.redhat.com [10.36.116.134]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8ABFA5C219; Sat, 30 Nov 2019 19:42:47 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 1FDE611366E6; Sat, 30 Nov 2019 20:42:41 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 08/21] exec: Fix latent file_ram_alloc() error handling bug Date: Sat, 30 Nov 2019 20:42:27 +0100 Message-Id: <20191130194240.10517-9-armbru@redhat.com> In-Reply-To: <20191130194240.10517-1-armbru@redhat.com> References: <20191130194240.10517-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: rIGtdbenONej9jLdE2_7DA-1 X-Mimecast-Spam-Score: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Igor Mammedov , vsementsov@virtuozzo.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" When os_mem_prealloc() fails, file_ram_alloc() calls qemu_ram_munmap() and returns null. Except it doesn't when its @errp argument is null, because it checks for failure with (errp && *errp). Messed up in commit 056b68af77 "fix qemu exit on memory hotplug when allocation fails at prealloc time". The bug can't bite as no caller actually passes null. Fix it anyway. Cc: Igor Mammedov Signed-off-by: Markus Armbruster Reviewed-by: Igor Mammedov --- exec.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/exec.c b/exec.c index ffdb518535..45695a5f2d 100644 --- a/exec.c +++ b/exec.c @@ -1841,6 +1841,7 @@ static void *file_ram_alloc(RAMBlock *block, bool truncate, Error **errp) { + Error *err = NULL; MachineState *ms = MACHINE(qdev_get_machine()); void *area; @@ -1898,8 +1899,9 @@ static void *file_ram_alloc(RAMBlock *block, } if (mem_prealloc) { - os_mem_prealloc(fd, area, memory, ms->smp.cpus, errp); - if (errp && *errp) { + os_mem_prealloc(fd, area, memory, ms->smp.cpus, &err); + if (err) { + error_propagate(errp, err); qemu_ram_munmap(fd, area, memory); return NULL; } From patchwork Sat Nov 30 19:42:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 11268127 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 472EB14B7 for ; Sat, 30 Nov 2019 19:56:20 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 13C2120732 for ; Sat, 30 Nov 2019 19:56:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="eeSy0kdk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 13C2120732 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37782 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8qp-0005ga-1G for patchwork-qemu-devel@patchwork.kernel.org; Sat, 30 Nov 2019 14:56:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53666) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8dx-0006ZB-AV for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:43:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ib8dv-0005Dg-30 for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:43:01 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:58791 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ib8du-00058P-NP for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:42:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575142974; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X9ohRhZMo4PHmP3e4xms+2hvoD8VFoiNZy3Ldir0HdM=; b=eeSy0kdkA+bbWAoUd78/xvxkibviBfUDclG4MyCVT9G3ckA/gFhsRAfbGN00+0ehsu9nR+ t+ltbwqgEu2jTQ4ASnADU01Myz+EJvC4jPfrl+V6J1qZBXI8eoS9hnzXoaTtdfjhZu1tjk 0xG3XDd9UYn71fALP1dWyrKuB648iE4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-416-WPtqNFc0MAiS_p9OoaEAfg-1; Sat, 30 Nov 2019 14:42:52 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C8B6480183D; Sat, 30 Nov 2019 19:42:51 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-134.ams2.redhat.com [10.36.116.134]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EC2115D6D6; Sat, 30 Nov 2019 19:42:48 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 2340A11366EC; Sat, 30 Nov 2019 20:42:41 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 09/21] hw/acpi: Fix latent legacy CPU plug error handling bug Date: Sat, 30 Nov 2019 20:42:28 +0100 Message-Id: <20191130194240.10517-10-armbru@redhat.com> In-Reply-To: <20191130194240.10517-1-armbru@redhat.com> References: <20191130194240.10517-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: WPtqNFc0MAiS_p9OoaEAfg-1 X-Mimecast-Spam-Score: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Igor Mammedov , vsementsov@virtuozzo.com, "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" legacy_acpi_cpu_plug_cb() crashes when acpi_set_cpu_present_bit() fails and its @errp argument is null. Messed up in commit cc43364de7 "acpi/cpu-hotplug: introduce helper function to keep bit setting in one place". The bug can't bite as no caller actually passes null, and acpi_set_cpu_present_bit() can't actually fail. Fix it anyway. Cc: "Michael S. Tsirkin" Cc: Igor Mammedov Signed-off-by: Markus Armbruster Reviewed-by: Igor Mammedov --- hw/acpi/cpu_hotplug.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/hw/acpi/cpu_hotplug.c b/hw/acpi/cpu_hotplug.c index 3ac2045a95..9c3bcc84de 100644 --- a/hw/acpi/cpu_hotplug.c +++ b/hw/acpi/cpu_hotplug.c @@ -55,8 +55,7 @@ static const MemoryRegionOps AcpiCpuHotplug_ops = { }, }; -static void acpi_set_cpu_present_bit(AcpiCpuHotplug *g, CPUState *cpu, - Error **errp) +static void acpi_set_cpu_present_bit(AcpiCpuHotplug *g, CPUState *cpu) { CPUClass *k = CPU_GET_CLASS(cpu); int64_t cpu_id; @@ -74,10 +73,7 @@ static void acpi_set_cpu_present_bit(AcpiCpuHotplug *g, CPUState *cpu, void legacy_acpi_cpu_plug_cb(HotplugHandler *hotplug_dev, AcpiCpuHotplug *g, DeviceState *dev, Error **errp) { - acpi_set_cpu_present_bit(g, CPU(dev), errp); - if (*errp != NULL) { - return; - } + acpi_set_cpu_present_bit(g, CPU(dev)); acpi_send_event(DEVICE(hotplug_dev), ACPI_CPU_HOTPLUG_STATUS); } @@ -92,7 +88,7 @@ void legacy_acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner, gpe_cpu->device = owner; CPU_FOREACH(cpu) { - acpi_set_cpu_present_bit(gpe_cpu, cpu, &error_abort); + acpi_set_cpu_present_bit(gpe_cpu, cpu); } } From patchwork Sat Nov 30 19:42:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 11268099 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B3C52109A for ; Sat, 30 Nov 2019 19:48:43 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8B3EF2073C for ; Sat, 30 Nov 2019 19:48:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SE4VSPAL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8B3EF2073C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37684 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8jS-00058y-8o for patchwork-qemu-devel@patchwork.kernel.org; Sat, 30 Nov 2019 14:48:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53557) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8du-0006Ug-LI for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:43:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ib8ds-0005BO-PU for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:42:58 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:21943 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ib8dq-000572-QQ for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:42:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575142973; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kRKNw1DGxjyDjzaLKcSU2qGKWJyyolVCSyH6uayqbcM=; b=SE4VSPALqjk1leivEw7G6OuZwKCx5c3HEUZwYYvaZAvfqbxk4sbEUafQU3mCjHeMiFL1Ix aeJ3GKnSyyVpAatmKMfIRewsocFWoeoxxPChFdnm6m2m+AL7qZsDK2P9kMWYxEy/o7LU/g RmZacnCtuagHZDJPVCPZbPj1OKoZp6A= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-299-eB47qqh7M8uHcTaxg42vVQ-1; Sat, 30 Nov 2019 14:42:50 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2A914800D4E; Sat, 30 Nov 2019 19:42:49 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-134.ams2.redhat.com [10.36.116.134]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EFAEA5D9E1; Sat, 30 Nov 2019 19:42:48 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 2675D11366F1; Sat, 30 Nov 2019 20:42:41 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 10/21] hw/core: Fix latent fit_load_fdt() error handling bug Date: Sat, 30 Nov 2019 20:42:29 +0100 Message-Id: <20191130194240.10517-11-armbru@redhat.com> In-Reply-To: <20191130194240.10517-1-armbru@redhat.com> References: <20191130194240.10517-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: eB47qqh7M8uHcTaxg42vVQ-1 X-Mimecast-Spam-Score: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: vsementsov@virtuozzo.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" fit_load_fdt() recovers from fit_image_addr() failing with ENOENT. Except it doesn't when its @errp argument is &error_fatal or &error_abort, because it blindly passes @errp to fit_image_addr(). Messed up in commit 3eb99edb48 "loader-fit: Wean off error_printf()". The bug can't bite as no caller actually passes &error_fatal or &error_abort. Fix it anyway. Signed-off-by: Markus Armbruster Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Vladimir Sementsov-Ogievskiy --- hw/core/loader-fit.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/hw/core/loader-fit.c b/hw/core/loader-fit.c index 953b16bc82..c465921b8f 100644 --- a/hw/core/loader-fit.c +++ b/hw/core/loader-fit.c @@ -178,11 +178,12 @@ static int fit_load_fdt(const struct fit_loader *ldr, const void *itb, int cfg, void *opaque, const void *match_data, hwaddr kernel_end, Error **errp) { + Error *err = NULL; const char *name; const void *data; const void *load_data; hwaddr load_addr; - int img_off, err; + int img_off; size_t sz; int ret; @@ -197,13 +198,13 @@ static int fit_load_fdt(const struct fit_loader *ldr, const void *itb, return -EINVAL; } - err = fit_image_addr(itb, img_off, "load", &load_addr, errp); - if (err == -ENOENT) { + ret = fit_image_addr(itb, img_off, "load", &load_addr, &err); + if (ret == -ENOENT) { load_addr = ROUND_UP(kernel_end, 64 * KiB) + (10 * MiB); - error_free(*errp); - } else if (err) { - error_prepend(errp, "unable to read FDT load address from FIT: "); - ret = err; + error_free(err); + } else if (ret) { + error_propagate_prepend(errp, err, + "unable to read FDT load address from FIT: "); goto out; } From patchwork Sat Nov 30 19:42:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 11268125 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4B679109A for ; Sat, 30 Nov 2019 19:54:34 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D55E420732 for ; Sat, 30 Nov 2019 19:54:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="eRMgFg7R" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D55E420732 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37752 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8p6-0003qo-No for patchwork-qemu-devel@patchwork.kernel.org; Sat, 30 Nov 2019 14:54:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53690) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8dx-0006aB-SO for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:43:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ib8du-0005Cz-MU for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:43:01 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:29590 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ib8ds-000578-Oz for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:42:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575142973; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3t/HhgZjzhBdRwBHKCZ+80RD28r4jF7bHY7IRHnb69k=; b=eRMgFg7Rq3sdymqbRdb5i9H8x7ri+4DviFyB7XDLKKYxvJkmwQrZLcQtvwCAozcgx1ytJc phuwWFdmCA3xxzcW4mmELA2/EY1areFZY/aUpZG2WxQpiBakz0dYpGqr7m7vWkayDoG8lC CihwLqJ1R+oSTGMA8MRuDjxXOI9f/ks= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-366-YSDmZVBYMWe0y6c7WTE_LQ-1; Sat, 30 Nov 2019 14:42:50 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2A1F210054E3; Sat, 30 Nov 2019 19:42:49 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-134.ams2.redhat.com [10.36.116.134]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EE96819C58; Sat, 30 Nov 2019 19:42:48 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 29B2A11366F2; Sat, 30 Nov 2019 20:42:41 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 11/21] hw/ipmi: Fix latent realize() error handling bugs Date: Sat, 30 Nov 2019 20:42:30 +0100 Message-Id: <20191130194240.10517-12-armbru@redhat.com> In-Reply-To: <20191130194240.10517-1-armbru@redhat.com> References: <20191130194240.10517-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: YSDmZVBYMWe0y6c7WTE_LQ-1 X-Mimecast-Spam-Score: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Corey Minyard , vsementsov@virtuozzo.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" isa_ipmi_bt_realize(), ipmi_isa_realize(), pci_ipmi_bt_realize(), and pci_ipmi_kcs_realize() crash when IPMIInterfaceClass method init() fails and their @errp argument is null. First messed up in commit 0719029c47 "ipmi: Add an ISA KCS low-level interface", then imitated in commit a9b74079cb "ipmi: Add a BT low-level interface" and commit 12f983c6aa "ipmi: Add PCI IPMI interfaces". The bug can't bite as no caller actually passes null, and none of the init() methods can actually fail. Fix it anyway. Cc: Corey Minyard Signed-off-by: Markus Armbruster --- hw/ipmi/isa_ipmi_bt.c | 7 +++++-- hw/ipmi/isa_ipmi_kcs.c | 7 +++++-- hw/ipmi/pci_ipmi_bt.c | 6 ++++-- hw/ipmi/pci_ipmi_kcs.c | 6 ++++-- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/hw/ipmi/isa_ipmi_bt.c b/hw/ipmi/isa_ipmi_bt.c index 9a87ffd3f0..9fba5ed383 100644 --- a/hw/ipmi/isa_ipmi_bt.c +++ b/hw/ipmi/isa_ipmi_bt.c @@ -70,6 +70,7 @@ static void isa_ipmi_bt_lower_irq(IPMIBT *ib) static void isa_ipmi_bt_realize(DeviceState *dev, Error **errp) { + Error *err = NULL; ISADevice *isadev = ISA_DEVICE(dev); ISAIPMIBTDevice *iib = ISA_IPMI_BT(dev); IPMIInterface *ii = IPMI_INTERFACE(dev); @@ -85,9 +86,11 @@ static void isa_ipmi_bt_realize(DeviceState *dev, Error **errp) iib->bt.bmc->intf = ii; iib->bt.opaque = iib; - iic->init(ii, 0, errp); - if (*errp) + iic->init(ii, 0, &err); + if (err) { + error_propagate(errp, err); return; + } if (iib->isairq > 0) { isa_init_irq(isadev, &iib->irq, iib->isairq); diff --git a/hw/ipmi/isa_ipmi_kcs.c b/hw/ipmi/isa_ipmi_kcs.c index ca3ea36a3f..cc6bd817f2 100644 --- a/hw/ipmi/isa_ipmi_kcs.c +++ b/hw/ipmi/isa_ipmi_kcs.c @@ -69,6 +69,7 @@ static void isa_ipmi_kcs_lower_irq(IPMIKCS *ik) static void ipmi_isa_realize(DeviceState *dev, Error **errp) { + Error *err = NULL; ISADevice *isadev = ISA_DEVICE(dev); ISAIPMIKCSDevice *iik = ISA_IPMI_KCS(dev); IPMIInterface *ii = IPMI_INTERFACE(dev); @@ -84,9 +85,11 @@ static void ipmi_isa_realize(DeviceState *dev, Error **errp) iik->kcs.bmc->intf = ii; iik->kcs.opaque = iik; - iic->init(ii, 0, errp); - if (*errp) + iic->init(ii, 0, &err); + if (err) { + error_propagate(errp, err); return; + } if (iik->isairq > 0) { isa_init_irq(isadev, &iik->irq, iik->isairq); diff --git a/hw/ipmi/pci_ipmi_bt.c b/hw/ipmi/pci_ipmi_bt.c index 6ed925a665..ba9cf016b5 100644 --- a/hw/ipmi/pci_ipmi_bt.c +++ b/hw/ipmi/pci_ipmi_bt.c @@ -54,6 +54,7 @@ static void pci_ipmi_lower_irq(IPMIBT *ik) static void pci_ipmi_bt_realize(PCIDevice *pd, Error **errp) { + Error *err = NULL; PCIIPMIBTDevice *pik = PCI_IPMI_BT(pd); IPMIInterface *ii = IPMI_INTERFACE(pd); IPMIInterfaceClass *iic = IPMI_INTERFACE_GET_CLASS(ii); @@ -74,8 +75,9 @@ static void pci_ipmi_bt_realize(PCIDevice *pd, Error **errp) pik->bt.raise_irq = pci_ipmi_raise_irq; pik->bt.lower_irq = pci_ipmi_lower_irq; - iic->init(ii, 8, errp); - if (*errp) { + iic->init(ii, 8, &err); + if (err) { + error_propagate(errp, err); return; } pci_register_bar(pd, 0, PCI_BASE_ADDRESS_SPACE_IO, &pik->bt.io); diff --git a/hw/ipmi/pci_ipmi_kcs.c b/hw/ipmi/pci_ipmi_kcs.c index eeba63baa4..99f46152f4 100644 --- a/hw/ipmi/pci_ipmi_kcs.c +++ b/hw/ipmi/pci_ipmi_kcs.c @@ -54,6 +54,7 @@ static void pci_ipmi_lower_irq(IPMIKCS *ik) static void pci_ipmi_kcs_realize(PCIDevice *pd, Error **errp) { + Error *err = NULL; PCIIPMIKCSDevice *pik = PCI_IPMI_KCS(pd); IPMIInterface *ii = IPMI_INTERFACE(pd); IPMIInterfaceClass *iic = IPMI_INTERFACE_GET_CLASS(ii); @@ -74,8 +75,9 @@ static void pci_ipmi_kcs_realize(PCIDevice *pd, Error **errp) pik->kcs.raise_irq = pci_ipmi_raise_irq; pik->kcs.lower_irq = pci_ipmi_lower_irq; - iic->init(ii, 8, errp); - if (*errp) { + iic->init(ii, 8, &err); + if (err) { + error_propagate(errp, err); return; } pci_register_bar(pd, 0, PCI_BASE_ADDRESS_SPACE_IO, &pik->kcs.io); From patchwork Sat Nov 30 19:42:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 11268107 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6B66F14B7 for ; Sat, 30 Nov 2019 19:51:02 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 424972075A for ; Sat, 30 Nov 2019 19:51:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Ll7KZcHR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 424972075A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37722 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8lh-0007vZ-0W for patchwork-qemu-devel@patchwork.kernel.org; Sat, 30 Nov 2019 14:51:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53637) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8dw-0006YD-Pa for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:43:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ib8du-0005Co-Lu for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:43:00 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:53230 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ib8dt-00056y-Sz for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:42:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575142973; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6+WDpTr2l+S+ufHYzRrbqlPbh/3TDGw8iJU+PKCkrjo=; b=Ll7KZcHRfqNxPZNHs8Y5cb4izbiCW9BTQDGUFXLa3nz9m9VlmySK1UEgCsNANq9SAoM3Hz wKLgy//IDVv/qRbZghojZWJMMABC8wGRECEIbLHXu8lpWVJootKoDf0TX6L4YhFPbgwlHY GQBefCOwfGqRdpltQIJ5iM4k3wpSkEo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-192-xQaGg6W7MmW7h5WDQbly0Q-1; Sat, 30 Nov 2019 14:42:50 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2F84B80183C; Sat, 30 Nov 2019 19:42:49 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-134.ams2.redhat.com [10.36.116.134]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F3A6F5D6D8; Sat, 30 Nov 2019 19:42:48 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 2D12111366F3; Sat, 30 Nov 2019 20:42:41 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 12/21] qga: Fix latent guest-get-fsinfo error handling bug Date: Sat, 30 Nov 2019 20:42:31 +0100 Message-Id: <20191130194240.10517-13-armbru@redhat.com> In-Reply-To: <20191130194240.10517-1-armbru@redhat.com> References: <20191130194240.10517-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: xQaGg6W7MmW7h5WDQbly0Q-1 X-Mimecast-Spam-Score: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: vsementsov@virtuozzo.com, Michael Roth Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" build_guest_fsinfo_for_virtual_device() crashes when build_guest_fsinfo_for_device() fails and its @errp argument is null. Messed up in commit 46d4c5723e "qga: Add guest-get-fsinfo command". The bug can't bite as no caller actually passes null. Fix it anyway. Cc: Michael Roth Signed-off-by: Markus Armbruster Reviewed-by: Vladimir Sementsov-Ogievskiy --- qga/commands-posix.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 1c1a165dae..0be527ccb8 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -1049,6 +1049,7 @@ static void build_guest_fsinfo_for_virtual_device(char const *syspath, GuestFilesystemInfo *fs, Error **errp) { + Error *err = NULL; DIR *dir; char *dirpath; struct dirent *entry; @@ -1078,10 +1079,11 @@ static void build_guest_fsinfo_for_virtual_device(char const *syspath, g_debug(" slave device '%s'", entry->d_name); path = g_strdup_printf("%s/slaves/%s", syspath, entry->d_name); - build_guest_fsinfo_for_device(path, fs, errp); + build_guest_fsinfo_for_device(path, fs, &err); g_free(path); - if (*errp) { + if (err) { + error_propagate(errp, err); break; } } From patchwork Sat Nov 30 19:42:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 11268137 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3FCEA15AB for ; Sat, 30 Nov 2019 20:00:35 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1701F20732 for ; Sat, 30 Nov 2019 20:00:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="fcTNGbe8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1701F20732 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37842 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8uv-0002U3-Sr for patchwork-qemu-devel@patchwork.kernel.org; Sat, 30 Nov 2019 15:00:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53640) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8dw-0006YM-V0 for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:43:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ib8dv-0005DV-2z for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:43:00 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:22916 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ib8du-0005Ac-PG for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:42:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575142976; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+dynwsHSBPSdNaS6/Bm4It61bKF8kebpsa7wwuPEPdY=; b=fcTNGbe8DiozWQqV2fdR44aFfZcYzJn7M0ByUh9kw1YuCOu5y+NtU9FNotGOPPeHj+kOWG ghG+6gvPmosxmlSFWDtsw8O3r9y9ZHIakObF4vweY07xAETa6GGAt1bV1DyKQYoy8OrT0z zNTpFEnzhzJ06wrlczTkmn0LU6Ev4EQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-212-NR7JGCSbN-OY7UmhITJ3Hw-1; Sat, 30 Nov 2019 14:42:52 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D2043800D41; Sat, 30 Nov 2019 19:42:51 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-134.ams2.redhat.com [10.36.116.134]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 01AE05D70E; Sat, 30 Nov 2019 19:42:49 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 303D911366F7; Sat, 30 Nov 2019 20:42:41 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 13/21] memory-device: Fix latent memory pre-plug error handling bugs Date: Sat, 30 Nov 2019 20:42:32 +0100 Message-Id: <20191130194240.10517-14-armbru@redhat.com> In-Reply-To: <20191130194240.10517-1-armbru@redhat.com> References: <20191130194240.10517-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: NR7JGCSbN-OY7UmhITJ3Hw-1 X-Mimecast-Spam-Score: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: vsementsov@virtuozzo.com, David Hildenbrand Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" memory_device_get_free_addr() crashes when memory_device_check_addable() fails and its @errp argument is null. Messed up in commit 1b6d6af21b "pc-dimm: factor out capacity and slot checks into MemoryDevice". The bug can't bite as no caller actually passes null. Fix it anyway. Cc: David Hildenbrand Signed-off-by: Markus Armbruster Reviewed-by: David Hildenbrand --- hw/mem/memory-device.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/mem/memory-device.c b/hw/mem/memory-device.c index aef148c1d7..4bc9cf0917 100644 --- a/hw/mem/memory-device.c +++ b/hw/mem/memory-device.c @@ -99,6 +99,7 @@ static uint64_t memory_device_get_free_addr(MachineState *ms, uint64_t align, uint64_t size, Error **errp) { + Error *err = NULL; GSList *list = NULL, *item; Range as, new = range_empty; @@ -123,8 +124,9 @@ static uint64_t memory_device_get_free_addr(MachineState *ms, return 0; } - memory_device_check_addable(ms, size, errp); - if (*errp) { + memory_device_check_addable(ms, size, &err); + if (err) { + error_propagate(errp, err); return 0; } From patchwork Sat Nov 30 19:42:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 11268129 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4AC1514B7 for ; Sat, 30 Nov 2019 19:56:25 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 20A2520732 for ; Sat, 30 Nov 2019 19:56:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="aZQyXUqx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 20A2520732 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37784 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8qt-0005n8-VH for patchwork-qemu-devel@patchwork.kernel.org; Sat, 30 Nov 2019 14:56:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53597) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8dv-0006Wf-T5 for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:43:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ib8du-0005Cp-Lr for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:42:59 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:40440 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ib8ds-0005Ab-O5 for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:42:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575142976; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g6s54Yx9MNo545FwLDDs16iRJ9KAV1CQQ70D0Qc5Xbg=; b=aZQyXUqxekN8ylM+kM9rNRss1jN2iiZncEpvW9/64w2QhGhE/qjKgzzDqW+gaIHxop1Zdy gv1SfxcIZp9rP4CyMHuP3SpGXcYzTdiIkyDhj+SqkHEZekRAwu2tEEdTU/RtQTfBPXhIeT ICHqx2eWpUEnawUkq41vduajxL6gblY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-212-20_MptBPOImtUrb2Gi73Ew-1; Sat, 30 Nov 2019 14:42:52 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EF9FB184CAB8; Sat, 30 Nov 2019 19:42:51 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-134.ams2.redhat.com [10.36.116.134]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 063AB19C5B; Sat, 30 Nov 2019 19:42:49 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 33716113639C; Sat, 30 Nov 2019 20:42:41 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 14/21] s390x/event-facility: Fix latent realize() error handling bug Date: Sat, 30 Nov 2019 20:42:33 +0100 Message-Id: <20191130194240.10517-15-armbru@redhat.com> In-Reply-To: <20191130194240.10517-1-armbru@redhat.com> References: <20191130194240.10517-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: 20_MptBPOImtUrb2Gi73Ew-1 X-Mimecast-Spam-Score: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cornelia Huck , vsementsov@virtuozzo.com, David Hildenbrand Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" sclp_events_bus_realize() crashes when object_property_set_bool() fails and its @errp argument is null. Messed up in commit f6102c329c "s390/sclp: rework sclp event facility initialization + device realization". The bug can't bite as no caller actually passes null. Fix it anyway. Cc: David Hildenbrand Cc: Cornelia Huck Signed-off-by: Markus Armbruster Reviewed-by: David Hildenbrand --- hw/s390x/event-facility.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c index 66205697ae..cdcf9154c4 100644 --- a/hw/s390x/event-facility.c +++ b/hw/s390x/event-facility.c @@ -339,14 +339,16 @@ out: static void sclp_events_bus_realize(BusState *bus, Error **errp) { + Error *err = NULL; BusChild *kid; /* TODO: recursive realization has to be done in common code */ QTAILQ_FOREACH(kid, &bus->children, sibling) { DeviceState *dev = kid->child; - object_property_set_bool(OBJECT(dev), true, "realized", errp); - if (*errp) { + object_property_set_bool(OBJECT(dev), true, "realized", &err); + if (errp) { + error_propagate(errp, err); return; } } From patchwork Sat Nov 30 19:42:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 11268111 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C7A1D14B7 for ; Sat, 30 Nov 2019 19:51:40 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9EDC120732 for ; Sat, 30 Nov 2019 19:51:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Sk7mbq8u" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9EDC120732 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37726 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8mJ-0000a9-DU for patchwork-qemu-devel@patchwork.kernel.org; Sat, 30 Nov 2019 14:51:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53604) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8dw-0006X5-8v for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:43:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ib8dv-0005DP-2B for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:43:00 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:51061 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ib8du-00058G-MK for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:42:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575142974; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XKOFNJ7AKoAjW1m5Bz8AzZ1gisR6NMx4PnfY9PjImjo=; b=Sk7mbq8uLtDNw0dOLDyNggIIUhjTvk64G4UPcZR9rF/kA81Pk47S04XfSjVUY3khWJbeRi X3v26Wh7JRd4MF/ACkpx00wT1EpIkI8STgbiJ+xt1UFPr6Ba6taC1Pd3ono8XPRlw0oZTs jeL5AKwhis0yWoL1sO06GoLd0wnoVoI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-24-woFdMWQ7PjWaBHd1tkYDmg-1; Sat, 30 Nov 2019 14:42:52 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E2611800D4E; Sat, 30 Nov 2019 19:42:51 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-134.ams2.redhat.com [10.36.116.134]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0A18D600C1; Sat, 30 Nov 2019 19:42:49 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 36A201135A56; Sat, 30 Nov 2019 20:42:41 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 15/21] s390x/cpu_models: Fix latent feature property error handling bugs Date: Sat, 30 Nov 2019 20:42:34 +0100 Message-Id: <20191130194240.10517-16-armbru@redhat.com> In-Reply-To: <20191130194240.10517-1-armbru@redhat.com> References: <20191130194240.10517-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: woFdMWQ7PjWaBHd1tkYDmg-1 X-Mimecast-Spam-Score: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cornelia Huck , vsementsov@virtuozzo.com, David Hildenbrand Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" s390x-cpu property setters set_feature() and set_feature_group() crash when the visitor fails and its @errp argument is null. Messed up in commit 0754f60429 "s390x/cpumodel: expose features and feature groups as properties". The bug can't bite as no caller actually passes null. Fix it anyway. Cc: David Hildenbrand Cc: Cornelia Huck Signed-off-by: Markus Armbruster Reviewed-by: David Hildenbrand --- target/s390x/cpu_models.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 7e92fb2e15..6a29fd3ab1 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -987,6 +987,7 @@ static void get_feature(Object *obj, Visitor *v, const char *name, static void set_feature(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { + Error *err = NULL; S390Feat feat = (S390Feat) opaque; DeviceState *dev = DEVICE(obj); S390CPU *cpu = S390_CPU(obj); @@ -1002,8 +1003,9 @@ static void set_feature(Object *obj, Visitor *v, const char *name, return; } - visit_type_bool(v, name, &value, errp); - if (*errp) { + visit_type_bool(v, name, &value, &err); + if (err) { + error_propagate(errp, err); return; } if (value) { @@ -1043,6 +1045,7 @@ static void get_feature_group(Object *obj, Visitor *v, const char *name, static void set_feature_group(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { + Error *err = NULL; S390FeatGroup group = (S390FeatGroup) opaque; const S390FeatGroupDef *def = s390_feat_group_def(group); DeviceState *dev = DEVICE(obj); @@ -1059,8 +1062,9 @@ static void set_feature_group(Object *obj, Visitor *v, const char *name, return; } - visit_type_bool(v, name, &value, errp); - if (*errp) { + visit_type_bool(v, name, &value, &err); + if (err) { + error_propagate(errp, err); return; } if (value) { From patchwork Sat Nov 30 19:42:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 11268121 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AAE48109A for ; Sat, 30 Nov 2019 19:53:55 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 81B8420732 for ; Sat, 30 Nov 2019 19:53:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="eeatA2yj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 81B8420732 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37744 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8oU-0002wr-6D for patchwork-qemu-devel@patchwork.kernel.org; Sat, 30 Nov 2019 14:53:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53656) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8dx-0006Yd-2j for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:43:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ib8du-0005Cd-L3 for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:43:00 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:32999 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ib8ds-000589-NS for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:42:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575142974; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bfhZK4iK/fF9bpGJNPVZYuytDwS0kE2F3pxBsnKfuA4=; b=eeatA2yjt1dcegqDycNrw6qtMvnubZAuew6ABKtFKGQlJUl/2pf0evslqNytd/a7HsbjcU 3TjGhQ7zNjtpnt9Y/Q6eqi1wWULS9DKiVHW9GnD/7+QLDe/9Ou6LxU9iigXRFpQ8pn56HD F0u98F/99vrTC53nVXuu7v4pPAi/O/c= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-416-XFitOcfoPxKm5THbQYyfdA-1; Sat, 30 Nov 2019 14:42:52 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E0EC7DB20; Sat, 30 Nov 2019 19:42:51 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-134.ams2.redhat.com [10.36.116.134]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0F0181001281; Sat, 30 Nov 2019 19:42:49 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 39DD61135A59; Sat, 30 Nov 2019 20:42:41 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 16/21] s390/cpu_modules: Fix latent realize() error handling bugs Date: Sat, 30 Nov 2019 20:42:35 +0100 Message-Id: <20191130194240.10517-17-armbru@redhat.com> In-Reply-To: <20191130194240.10517-1-armbru@redhat.com> References: <20191130194240.10517-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: XFitOcfoPxKm5THbQYyfdA-1 X-Mimecast-Spam-Score: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cornelia Huck , vsementsov@virtuozzo.com, David Hildenbrand Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" get_max_cpu_model() crashes when kvm_s390_get_host_cpu_model() fails and its @errp argument is null. apply_cpu_model() crashes when kvm_s390_apply_cpu_model() fails and its @errp argument is null. s390_realize_cpu_model() crashes when get_max_cpu_model() or check_compatibility() fail, and its @errp argument is null. All three messed up in commit 80560137cf "s390x/cpumodel: check and apply the CPU model". The bugs can't bite as no caller actually passes null. Fix them anyway. Cc: David Hildenbrand Cc: Cornelia Huck Signed-off-by: Markus Armbruster Reviewed-by: David Hildenbrand --- target/s390x/cpu_models.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 6a29fd3ab1..c702e34a26 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -870,6 +870,7 @@ static void check_compatibility(const S390CPUModel *max_model, static S390CPUModel *get_max_cpu_model(Error **errp) { + Error *err = NULL; static S390CPUModel max_model; static bool cached; @@ -878,22 +879,24 @@ static S390CPUModel *get_max_cpu_model(Error **errp) } if (kvm_enabled()) { - kvm_s390_get_host_cpu_model(&max_model, errp); + kvm_s390_get_host_cpu_model(&max_model, &err); } else { max_model.def = s390_find_cpu_def(QEMU_MAX_CPU_TYPE, QEMU_MAX_CPU_GEN, QEMU_MAX_CPU_EC_GA, NULL); bitmap_copy(max_model.features, qemu_max_cpu_feat, S390_FEAT_MAX); - } - if (!*errp) { - cached = true; - return &max_model; } - return NULL; + if (err) { + error_propagate(errp, err); + return NULL; + } + cached = true; + return &max_model; } static inline void apply_cpu_model(const S390CPUModel *model, Error **errp) { #ifndef CONFIG_USER_ONLY + Error *err = NULL; static S390CPUModel applied_model; static bool applied; @@ -909,20 +912,23 @@ static inline void apply_cpu_model(const S390CPUModel *model, Error **errp) } if (kvm_enabled()) { - kvm_s390_apply_cpu_model(model, errp); + kvm_s390_apply_cpu_model(model, &err); + if (err) { + error_propagate(errp, err); + return; + } } - if (!*errp) { - applied = true; - if (model) { - applied_model = *model; - } + applied = true; + if (model) { + applied_model = *model; } #endif } void s390_realize_cpu_model(CPUState *cs, Error **errp) { + Error *err = NULL; S390CPUClass *xcc = S390_CPU_GET_CLASS(cs); S390CPU *cpu = S390_CPU(cs); const S390CPUModel *max_model; @@ -939,7 +945,7 @@ void s390_realize_cpu_model(CPUState *cs, Error **errp) } max_model = get_max_cpu_model(errp); - if (*errp) { + if (!max_model) { error_prepend(errp, "CPU models are not available: "); return; } @@ -951,8 +957,9 @@ void s390_realize_cpu_model(CPUState *cs, Error **errp) cpu->model->cpu_ver = max_model->cpu_ver; check_consistency(cpu->model); - check_compatibility(max_model, cpu->model, errp); - if (*errp) { + check_compatibility(max_model, cpu->model, &err); + if (err) { + error_propagate(errp, err); return; } From patchwork Sat Nov 30 19:42:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 11268139 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 49D0915AB for ; Sat, 30 Nov 2019 20:02:25 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1712E20732 for ; Sat, 30 Nov 2019 20:02:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="TACeyDGH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1712E20732 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37878 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8wi-0003yp-7A for patchwork-qemu-devel@patchwork.kernel.org; Sat, 30 Nov 2019 15:02:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53682) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8dx-0006Zv-Jx for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:43:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ib8dv-0005DX-2X for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:43:01 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:23562 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ib8du-00058t-M8 for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:42:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575142974; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lwveq/Hd1QbJmTtcX2t0aVbraIXH0lWuf5V+vTtMWvM=; b=TACeyDGHsd9S/0cmzE+f7QHTx4spedE5eOcV4bOzfofw+4q4gyQqzxOKvLOtyl0NltBbLY 2cE0ti+lrmMurjuTAhpkPMDQS3guFqRZdk9KojiiXDapwf1g2XWW2A6pcs8vb8V6Be2mFe BNfiWBxYqkYo7bXWimun6k4Z97qKKeU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-266-2qicZGfxP_KjNJUjYTuOFQ-1; Sat, 30 Nov 2019 14:42:51 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7A4721005502; Sat, 30 Nov 2019 19:42:50 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-134.ams2.redhat.com [10.36.116.134]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 22A74611DB; Sat, 30 Nov 2019 19:42:50 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 3D2E81135A5A; Sat, 30 Nov 2019 20:42:41 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 17/21] s390x: Fix latent query-cpu-model-FOO error handling bugs Date: Sat, 30 Nov 2019 20:42:36 +0100 Message-Id: <20191130194240.10517-18-armbru@redhat.com> In-Reply-To: <20191130194240.10517-1-armbru@redhat.com> References: <20191130194240.10517-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: 2qicZGfxP_KjNJUjYTuOFQ-1 X-Mimecast-Spam-Score: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cornelia Huck , vsementsov@virtuozzo.com, David Hildenbrand Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" cpu_model_from_info() is a helper for qmp_query_cpu_model_expansion(), qmp_query_cpu_model_comparison(), qmp_query_cpu_model_baseline(). It crashes when the visitor or the QOM setter fails, and its @errp argument is null. Messed up in commit 137974cea3 's390x/cpumodel: implement QMP interface "query-cpu-model-expansion"'. Its three callers have the same bug. Messed up in commit 4e82ef0502 's390x/cpumodel: implement QMP interface "query-cpu-model-comparison"' and commit f1a47d08ef 's390x/cpumodel: implement QMP interface "query-cpu-model-baseline"'. The bugs can't bite as no caller actually passes null. Fix them anyway. Cc: David Hildenbrand Cc: Cornelia Huck Signed-off-by: Markus Armbruster Reviewed-by: David Hildenbrand --- target/s390x/cpu_models.c | 43 ++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index c702e34a26..3ed301b5e5 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -477,6 +477,7 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) static void cpu_model_from_info(S390CPUModel *model, const CpuModelInfo *info, Error **errp) { + Error *err = NULL; const QDict *qdict = NULL; const QDictEntry *e; Visitor *visitor; @@ -513,24 +514,26 @@ static void cpu_model_from_info(S390CPUModel *model, const CpuModelInfo *info, if (qdict) { visitor = qobject_input_visitor_new(info->props); - visit_start_struct(visitor, NULL, NULL, 0, errp); - if (*errp) { + visit_start_struct(visitor, NULL, NULL, 0, &err); + if (err) { + error_propagate(errp, err); visit_free(visitor); object_unref(obj); return; } for (e = qdict_first(qdict); e; e = qdict_next(qdict, e)) { - object_property_set(obj, visitor, e->key, errp); - if (*errp) { + object_property_set(obj, visitor, e->key, &err); + if (err) { break; } } - if (!*errp) { + if (!err) { visit_check_struct(visitor, errp); } visit_end_struct(visitor, NULL); visit_free(visitor); - if (*errp) { + if (err) { + error_propagate(errp, err); object_unref(obj); return; } @@ -595,13 +598,15 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type, CpuModelInfo *model, Error **errp) { + Error *err = NULL; CpuModelExpansionInfo *expansion_info = NULL; S390CPUModel s390_model; bool delta_changes = false; /* convert it to our internal representation */ - cpu_model_from_info(&s390_model, model, errp); - if (*errp) { + cpu_model_from_info(&s390_model, model, &err); + if (err) { + error_propagate(errp, err); return NULL; } @@ -634,18 +639,21 @@ CpuModelCompareInfo *qmp_query_cpu_model_comparison(CpuModelInfo *infoa, CpuModelInfo *infob, Error **errp) { + Error *err = NULL; CpuModelCompareResult feat_result, gen_result; CpuModelCompareInfo *compare_info; S390FeatBitmap missing, added; S390CPUModel modela, modelb; /* convert both models to our internal representation */ - cpu_model_from_info(&modela, infoa, errp); - if (*errp) { + cpu_model_from_info(&modela, infoa, &err); + if (err) { + error_propagate(errp, err); return NULL; } - cpu_model_from_info(&modelb, infob, errp); - if (*errp) { + cpu_model_from_info(&modelb, infob, &err); + if (err) { + error_propagate(errp, err); return NULL; } compare_info = g_new0(CpuModelCompareInfo, 1); @@ -707,6 +715,7 @@ CpuModelBaselineInfo *qmp_query_cpu_model_baseline(CpuModelInfo *infoa, CpuModelInfo *infob, Error **errp) { + Error *err = NULL; CpuModelBaselineInfo *baseline_info; S390CPUModel modela, modelb, model; uint16_t cpu_type; @@ -714,13 +723,15 @@ CpuModelBaselineInfo *qmp_query_cpu_model_baseline(CpuModelInfo *infoa, uint8_t max_gen; /* convert both models to our internal representation */ - cpu_model_from_info(&modela, infoa, errp); - if (*errp) { + cpu_model_from_info(&modela, infoa, &err); + if (err) { + error_propagate(errp, err); return NULL; } - cpu_model_from_info(&modelb, infob, errp); - if (*errp) { + cpu_model_from_info(&modelb, infob, &err); + if (err) { + error_propagate(errp, err); return NULL; } From patchwork Sat Nov 30 19:42:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 11268091 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 35BD114B7 for ; Sat, 30 Nov 2019 19:47:55 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0D1AF2073C for ; Sat, 30 Nov 2019 19:47:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="h0E4Fm6t" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0D1AF2073C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8if-0004DQ-D6 for patchwork-qemu-devel@patchwork.kernel.org; Sat, 30 Nov 2019 14:47:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53667) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8dx-0006ZC-CM for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:43:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ib8dv-0005Dn-4q for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:43:01 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:49538 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ib8du-0005Bg-T9 for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:42:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575142976; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IzScTi0f13u/09c3vl32cClyMnYp+cJJAy0b4UZrYmo=; b=h0E4Fm6tu0IHKU6MCkLg73OojrGv0DGeVy/WCgb5OQt+TCrSTucjcW2cq/dbhT5POK3cuY DNF0cC92ZSpUB22nCW8UHHpN0EImP1PS3h9jbhXX1iqkj6YxULWXbLSX9lBh4Y2EebQMM7 oP/pNQRiDVYzX8m9oY0BDNwNApSmEAA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-211-FHyFTlptOQKGHPVuX3yJ6w-1; Sat, 30 Nov 2019 14:42:53 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7BBC110054E3; Sat, 30 Nov 2019 19:42:52 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-134.ams2.redhat.com [10.36.116.134]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2C3375D9E1; Sat, 30 Nov 2019 19:42:50 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 40B921135A63; Sat, 30 Nov 2019 20:42:41 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 18/21] s390x: Fix latent query-cpu-definitions error handling bug Date: Sat, 30 Nov 2019 20:42:37 +0100 Message-Id: <20191130194240.10517-19-armbru@redhat.com> In-Reply-To: <20191130194240.10517-1-armbru@redhat.com> References: <20191130194240.10517-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: FHyFTlptOQKGHPVuX3yJ6w-1 X-Mimecast-Spam-Score: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cornelia Huck , vsementsov@virtuozzo.com, David Hildenbrand Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" qmp_query_cpu_definitions() tries to ignore get_max_cpu_model()'s errors. However, it crashes when its @errp argument is null or &error_abort, and exit(1)s when it's &error_fatal. Messed up in commit 38cba1f4d8 "s390x: return unavailable features via query-cpu-definitions". The bug can't bite as no caller actually passes such @errp values. Fix it anyway. Cc: David Hildenbrand Cc: Cornelia Huck Signed-off-by: Markus Armbruster Reviewed-by: David Hildenbrand --- target/s390x/cpu_models.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 3ed301b5e5..547bab8ac3 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -462,11 +462,7 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) .list = NULL, }; - list_data.model = get_max_cpu_model(errp); - if (*errp) { - error_free(*errp); - *errp = NULL; - } + list_data.model = get_max_cpu_model(NULL); object_class_foreach(create_cpu_model_list, TYPE_S390_CPU, false, &list_data); From patchwork Sat Nov 30 19:42:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 11268085 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 277AC109A for ; Sat, 30 Nov 2019 19:44:45 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F33582084E for ; Sat, 30 Nov 2019 19:44:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="OoWMLXON" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F33582084E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37640 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8fb-0008Mb-Ux for patchwork-qemu-devel@patchwork.kernel.org; Sat, 30 Nov 2019 14:44:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53556) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8du-0006Uf-LB for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:43:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ib8ds-0005B9-O5 for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:42:58 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:38178 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ib8dq-000583-Q8 for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:42:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575142974; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9Y98JwQw/Ngdi+JlWevYq0UaxfD8K8BRDlr37ANqfxo=; b=OoWMLXONgggeLeXd0/G46ujpKTarp2JxnTPuTUFlvPhdLGX+Hc8UJFIAh/J8kMu5UfBzZa fUE7ZZCdCXv0wirA1vDAQ1z4vyopNghTsED3OqYx9MkcM+0b5ks/EwXrVUd3//nESY3IHt SNIQJ+2AmTIUR+4dSYaP28no+wuFd6Y= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-261-TKym0NMzNS-6YutoBI-FHA-1; Sat, 30 Nov 2019 14:42:51 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8B480107ACC4; Sat, 30 Nov 2019 19:42:50 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-134.ams2.redhat.com [10.36.116.134]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 31681600C8; Sat, 30 Nov 2019 19:42:50 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 43FC71135A64; Sat, 30 Nov 2019 20:42:41 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 19/21] error: Clean up unusual names of Error * variables Date: Sat, 30 Nov 2019 20:42:38 +0100 Message-Id: <20191130194240.10517-20-armbru@redhat.com> In-Reply-To: <20191130194240.10517-1-armbru@redhat.com> References: <20191130194240.10517-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: TKym0NMzNS-6YutoBI-FHA-1 X-Mimecast-Spam-Score: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: vsementsov@virtuozzo.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Local Error * variables are conventionally named @err or @local_err, and Error ** parameters @errp. Naming local variables like parameters is confusing. Clean that up. Naming parameters like local variables is also confusing. Left for another day. Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daudé --- hw/intc/s390_flic_kvm.c | 10 +++++----- hw/ppc/spapr_pci.c | 16 ++++++++-------- hw/ppc/spapr_pci_nvlink2.c | 10 +++++----- tests/test-blockjob.c | 16 ++++++++-------- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/hw/intc/s390_flic_kvm.c b/hw/intc/s390_flic_kvm.c index c9ee80eaae..30d50c2369 100644 --- a/hw/intc/s390_flic_kvm.c +++ b/hw/intc/s390_flic_kvm.c @@ -582,10 +582,10 @@ static void kvm_s390_flic_realize(DeviceState *dev, Error **errp) struct kvm_create_device cd = {0}; struct kvm_device_attr test_attr = {0}; int ret; - Error *errp_local = NULL; + Error *err = NULL; - KVM_S390_FLIC_GET_CLASS(dev)->parent_realize(dev, &errp_local); - if (errp_local) { + KVM_S390_FLIC_GET_CLASS(dev)->parent_realize(dev, &err); + if (err) { goto fail; } flic_state->fd = -1; @@ -593,7 +593,7 @@ static void kvm_s390_flic_realize(DeviceState *dev, Error **errp) cd.type = KVM_DEV_TYPE_FLIC; ret = kvm_vm_ioctl(kvm_state, KVM_CREATE_DEVICE, &cd); if (ret < 0) { - error_setg_errno(&errp_local, errno, "Creating the KVM device failed"); + error_setg_errno(&err, errno, "Creating the KVM device failed"); trace_flic_create_device(errno); goto fail; } @@ -605,7 +605,7 @@ static void kvm_s390_flic_realize(DeviceState *dev, Error **errp) KVM_HAS_DEVICE_ATTR, test_attr); return; fail: - error_propagate(errp, errp_local); + error_propagate(errp, err); } static void kvm_s390_flic_reset(DeviceState *dev) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index f6fbcf99ed..723373de73 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -2042,13 +2042,13 @@ void spapr_phb_dma_reset(SpaprPhbState *sphb) static void spapr_phb_reset(DeviceState *qdev) { SpaprPhbState *sphb = SPAPR_PCI_HOST_BRIDGE(qdev); - Error *errp = NULL; + Error *err = NULL; spapr_phb_dma_reset(sphb); spapr_phb_nvgpu_free(sphb); - spapr_phb_nvgpu_setup(sphb, &errp); - if (errp) { - error_report_err(errp); + spapr_phb_nvgpu_setup(sphb, &err); + if (err) { + error_report_err(err); } /* Reset the IOMMU state */ @@ -2326,7 +2326,7 @@ int spapr_dt_phb(SpaprMachineState *spapr, SpaprPhbState *phb, cpu_to_be32(phb->numa_node)}; SpaprTceTable *tcet; SpaprDrc *drc; - Error *errp = NULL; + Error *err = NULL; /* Start populating the FDT */ _FDT(bus_off = fdt_add_subnode(fdt, 0, phb->dtbusname)); @@ -2408,9 +2408,9 @@ int spapr_dt_phb(SpaprMachineState *spapr, SpaprPhbState *phb, return ret; } - spapr_phb_nvgpu_populate_dt(phb, fdt, bus_off, &errp); - if (errp) { - error_report_err(errp); + spapr_phb_nvgpu_populate_dt(phb, fdt, bus_off, &err); + if (err) { + error_report_err(err); } spapr_phb_nvgpu_ram_populate_dt(phb, fdt); diff --git a/hw/ppc/spapr_pci_nvlink2.c b/hw/ppc/spapr_pci_nvlink2.c index 4aa89ede23..8332d5694e 100644 --- a/hw/ppc/spapr_pci_nvlink2.c +++ b/hw/ppc/spapr_pci_nvlink2.c @@ -57,7 +57,7 @@ struct SpaprPhbPciNvGpuConfig { uint64_t nv2_atsd_current; int num; /* number of non empty (i.e. tgt!=0) entries in slots[] */ SpaprPhbPciNvGpuSlot slots[NVGPU_MAX_NUM]; - Error *errp; + Error *err; }; static SpaprPhbPciNvGpuSlot * @@ -153,7 +153,7 @@ static void spapr_phb_pci_collect_nvgpu(PCIBus *bus, PCIDevice *pdev, spapr_pci_collect_nvnpu(nvgpus, pdev, tgt, MEMORY_REGION(mr_npu), &local_err); } - error_propagate(&nvgpus->errp, local_err); + error_propagate(&nvgpus->err, local_err); } if ((pci_default_read_config(pdev, PCI_HEADER_TYPE, 1) != PCI_HEADER_TYPE_BRIDGE)) { @@ -187,9 +187,9 @@ void spapr_phb_nvgpu_setup(SpaprPhbState *sphb, Error **errp) pci_for_each_device(bus, pci_bus_num(bus), spapr_phb_pci_collect_nvgpu, sphb->nvgpus); - if (sphb->nvgpus->errp) { - error_propagate(errp, sphb->nvgpus->errp); - sphb->nvgpus->errp = NULL; + if (sphb->nvgpus->err) { + error_propagate(errp, sphb->nvgpus->err); + sphb->nvgpus->err = NULL; goto cleanup_exit; } diff --git a/tests/test-blockjob.c b/tests/test-blockjob.c index 7844c9ffcb..e670a20617 100644 --- a/tests/test-blockjob.c +++ b/tests/test-blockjob.c @@ -34,13 +34,13 @@ static BlockJob *mk_job(BlockBackend *blk, const char *id, int flags) { BlockJob *job; - Error *errp = NULL; + Error *err = NULL; job = block_job_create(id, drv, NULL, blk_bs(blk), 0, BLK_PERM_ALL, 0, flags, block_job_cb, - NULL, &errp); + NULL, &err); if (should_succeed) { - g_assert_null(errp); + g_assert_null(err); g_assert_nonnull(job); if (id) { g_assert_cmpstr(job->job.id, ==, id); @@ -48,9 +48,9 @@ static BlockJob *mk_job(BlockBackend *blk, const char *id, g_assert_cmpstr(job->job.id, ==, blk_name(blk)); } } else { - g_assert_nonnull(errp); + g_assert_nonnull(err); g_assert_null(job); - error_free(errp); + error_free(err); } return job; @@ -80,9 +80,9 @@ static BlockBackend *create_blk(const char *name) bdrv_unref(bs); if (name) { - Error *errp = NULL; - monitor_add_blk(blk, name, &errp); - g_assert_null(errp); + Error *err = NULL; + monitor_add_blk(blk, name, &err); + g_assert_null(err); } return blk; From patchwork Sat Nov 30 19:42:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 11268135 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7718115AB for ; Sat, 30 Nov 2019 20:00:32 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1A5B520732 for ; Sat, 30 Nov 2019 20:00:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PRRBV4WR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1A5B520732 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37840 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8us-0002Ox-Qi for patchwork-qemu-devel@patchwork.kernel.org; Sat, 30 Nov 2019 15:00:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53673) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8dx-0006ZU-DQ for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:43:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ib8dv-0005Dz-5F for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:43:01 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:49912 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ib8du-0005An-U7 for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:42:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575142976; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+6r20tme1c3K1oItK55VjhZNP4i1wewMOCLwqCimvoE=; b=PRRBV4WR4pKNXKfHpcYILi1xHZ8qSIi9QKplOISlVIeX++2h/uAvNzntPdlXHHHvmiujLq bcE60AZ1OlvglGJ1Ys+Uq/x8dN/TJS/uiaiwEg1vu1ZZpsnMxshCKMkfXJtQljZygmOs8u SxqP+2CbhLZyD0z0+WOPEmkvCHWRNM0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-266-tflcyL6LMEmznqfwm4cVFg-1; Sat, 30 Nov 2019 14:42:51 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 66772DB21; Sat, 30 Nov 2019 19:42:50 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-134.ams2.redhat.com [10.36.116.134]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 354586608A; Sat, 30 Nov 2019 19:42:50 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 487DE1135A70; Sat, 30 Nov 2019 20:42:41 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 20/21] hw/intc/s390: Simplify error handling in kvm_s390_flic_realize() Date: Sat, 30 Nov 2019 20:42:39 +0100 Message-Id: <20191130194240.10517-21-armbru@redhat.com> In-Reply-To: <20191130194240.10517-1-armbru@redhat.com> References: <20191130194240.10517-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: tflcyL6LMEmznqfwm4cVFg-1 X-Mimecast-Spam-Score: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Halil Pasic , Christian Borntraeger , vsementsov@virtuozzo.com, Cornelia Huck Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Cc: Halil Pasic Cc: Cornelia Huck Cc: Christian Borntraeger Signed-off-by: Markus Armbruster Reviewed-by: Cornelia Huck Acked-by: Halil Pasic --- hw/intc/s390_flic_kvm.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/hw/intc/s390_flic_kvm.c b/hw/intc/s390_flic_kvm.c index 30d50c2369..dddd33ea61 100644 --- a/hw/intc/s390_flic_kvm.c +++ b/hw/intc/s390_flic_kvm.c @@ -586,16 +586,17 @@ static void kvm_s390_flic_realize(DeviceState *dev, Error **errp) KVM_S390_FLIC_GET_CLASS(dev)->parent_realize(dev, &err); if (err) { - goto fail; + error_propagate(errp, err); + return; } flic_state->fd = -1; cd.type = KVM_DEV_TYPE_FLIC; ret = kvm_vm_ioctl(kvm_state, KVM_CREATE_DEVICE, &cd); if (ret < 0) { - error_setg_errno(&err, errno, "Creating the KVM device failed"); + error_setg_errno(errp, errno, "Creating the KVM device failed"); trace_flic_create_device(errno); - goto fail; + return; } flic_state->fd = cd.fd; @@ -603,9 +604,6 @@ static void kvm_s390_flic_realize(DeviceState *dev, Error **errp) test_attr.group = KVM_DEV_FLIC_CLEAR_IO_IRQ; flic_state->clear_io_supported = !ioctl(flic_state->fd, KVM_HAS_DEVICE_ATTR, test_attr); - return; -fail: - error_propagate(errp, err); } static void kvm_s390_flic_reset(DeviceState *dev) From patchwork Sat Nov 30 19:42:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 11268131 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BB408138C for ; Sat, 30 Nov 2019 19:58:13 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 924E820732 for ; Sat, 30 Nov 2019 19:58:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="iz0PkQCj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 924E820732 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37800 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8se-0008Io-Ha for patchwork-qemu-devel@patchwork.kernel.org; Sat, 30 Nov 2019 14:58:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53671) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ib8dx-0006ZQ-Du for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:43:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ib8dv-0005Ds-56 for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:43:01 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:43702 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ib8du-0005At-Tr for qemu-devel@nongnu.org; Sat, 30 Nov 2019 14:42:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575142976; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EWvrl1pKOWhXc6iPI2xLC14ZPehO6iBLbuWEKAUPc0E=; b=iz0PkQCjcyr5OGSGuAvHObYWPSefnhPOzBjNXPX1eiRhNqSsFuNDeXxHorsPmq6FA6LCwD UDjPfWV1FgXRO8zTNkJBL7KHTiz/gOsn9H/AhylBAgI+WZX4FvPqTP81gSZ08/UZsf3dnR nLXLt5r0YH9jPQwxcDgZTvauT4keUI8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-289--thBDBbtPHudv2mPSAZVPA-1; Sat, 30 Nov 2019 14:42:51 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 90B1A107ACC5; Sat, 30 Nov 2019 19:42:50 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-134.ams2.redhat.com [10.36.116.134]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 63351600C9; Sat, 30 Nov 2019 19:42:50 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 4BA7011358A3; Sat, 30 Nov 2019 20:42:41 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 21/21] tests-blockjob: Use error_free_or_abort() Date: Sat, 30 Nov 2019 20:42:40 +0100 Message-Id: <20191130194240.10517-22-armbru@redhat.com> In-Reply-To: <20191130194240.10517-1-armbru@redhat.com> References: <20191130194240.10517-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: -thBDBbtPHudv2mPSAZVPA-1 X-Mimecast-Spam-Score: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: vsementsov@virtuozzo.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- tests/test-blockjob.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/test-blockjob.c b/tests/test-blockjob.c index e670a20617..4eeb184caf 100644 --- a/tests/test-blockjob.c +++ b/tests/test-blockjob.c @@ -48,9 +48,8 @@ static BlockJob *mk_job(BlockBackend *blk, const char *id, g_assert_cmpstr(job->job.id, ==, blk_name(blk)); } } else { - g_assert_nonnull(err); + error_free_or_abort(&err); g_assert_null(job); - error_free(err); } return job;