From patchwork Wed Dec 4 09:36:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 11272683 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 92C23138C for ; Wed, 4 Dec 2019 10:05:58 +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 679DF206DF for ; Wed, 4 Dec 2019 10:05:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="KZJQM1V+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 679DF206DF 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]:36410 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icRXe-0001BA-KK for patchwork-qemu-devel@patchwork.kernel.org; Wed, 04 Dec 2019 05:05:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38577) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icR5P-0007Cj-82 for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icR5E-00004w-4S for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:36 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:32101 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 1icR5D-0008Mf-Va for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575452189; 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=KZJQM1V+IZL0jLNsnv1C24dahWOCOgjHzrN1toaEGomkoJ3sbsyph4nrH7Lda3T6nrbRO0 Ynw2y/Dvpfyl/oGFVH5DRoraJwdfJA5vw41If/ykSc/W2Z5TAvkIcfYuIRZVglrExNh7an eacufnXH7v+vJh29oWGIzcQhq5qdrz4= 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-276-u0GUppxHO-KEEOmANgB0Gg-1; Wed, 04 Dec 2019 04:36:28 -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 362F78017DF for ; Wed, 4 Dec 2019 09:36:27 +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 03A49600CC; Wed, 4 Dec 2019 09:36:27 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 85E0D11385C7; Wed, 4 Dec 2019 10:36:25 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 01/18] crypto: Fix certificate file error handling crash bug Date: Wed, 4 Dec 2019 10:36:08 +0100 Message-Id: <20191204093625.14836-2-armbru@redhat.com> In-Reply-To: <20191204093625.14836-1-armbru@redhat.com> References: <20191204093625.14836-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: u0GUppxHO-KEEOmANgB0Gg-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: =?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 Acked-by: Daniel P. Berrangé --- 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 Wed Dec 4 09:36:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 11272705 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 35AE214B7 for ; Wed, 4 Dec 2019 10:18: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 0A96620675 for ; Wed, 4 Dec 2019 10:18:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Zc+RSxkL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0A96620675 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]:36492 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icRjo-0005yI-8A for patchwork-qemu-devel@patchwork.kernel.org; Wed, 04 Dec 2019 05:18:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38433) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icR5K-0007Bs-Gx for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icR5E-000051-4j for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:34 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:43854 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 1icR5E-0008O5-02 for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575452189; 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=Zc+RSxkLrKIl4vZWD8LabiseQC8WrYTZIttZRqahDaDHFJiw6ZMuw8XrJe9/FvNSC+EV4A vbCusAtIl0EPQwrGfkjwQrLtTITsf1ygyPUDNDhT00nauVfdAl8KD1HzwnlV+g62aXH55y DgEtVtxlysTwGoaHfAVwJvpjMr86B5w= 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-100-bC-dmC6TOVy0UdIxbQmB1A-1; Wed, 04 Dec 2019 04:36:28 -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 36B69800D54 for ; Wed, 4 Dec 2019 09:36:27 +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 052C1600CD; Wed, 4 Dec 2019 09:36:27 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 888B511366CC; Wed, 4 Dec 2019 10:36:25 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 02/18] crypto: Fix typo in QCryptoTLSSession's comment Date: Wed, 4 Dec 2019 10:36:09 +0100 Message-Id: <20191204093625.14836-3-armbru@redhat.com> In-Reply-To: <20191204093625.14836-1-armbru@redhat.com> References: <20191204093625.14836-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: bC-dmC6TOVy0UdIxbQmB1A-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: =?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 Acked-by: Daniel P. Berrangé --- 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 Wed Dec 4 09:36:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 11272725 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 09555109A for ; Wed, 4 Dec 2019 10:39:38 +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 D2D102068E for ; Wed, 4 Dec 2019 10:39:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="et88UFRF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D2D102068E 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]:36630 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icS4H-0007l6-0n for patchwork-qemu-devel@patchwork.kernel.org; Wed, 04 Dec 2019 05:39:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38945) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icR5Y-0007FG-9P for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icR5F-00009t-8f for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:44 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:59425 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 1icR5F-0008Mr-4J for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575452189; 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=et88UFRFcVj4gGwEtEhVP2ZTbRBehzBTZ6rJNxab+433PbB8wF62HyNTcLRRtymRRr7j1B tqudrdNtvleQ4NqLFwph7QXtRcAHNDiIzMaBeo96/YMJ+V/V9QXNn2V5WDfInE+R95GXrG ciSdDVFV6lOEpJuaa/HK1a3qxK967mc= 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-407-J9p1byTTM3a4AA3TGpsfHA-1; Wed, 04 Dec 2019 04:36:28 -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 3D8CC800D5A for ; Wed, 4 Dec 2019 09:36:27 +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 0B43C1001938; Wed, 4 Dec 2019 09:36:27 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8BC8911366CF; Wed, 4 Dec 2019 10:36:25 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 03/18] io: Fix Error usage in a comment Date: Wed, 4 Dec 2019 10:36:10 +0100 Message-Id: <20191204093625.14836-4-armbru@redhat.com> In-Reply-To: <20191204093625.14836-1-armbru@redhat.com> References: <20191204093625.14836-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: J9p1byTTM3a4AA3TGpsfHA-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: =?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 Acked-by: Daniel P. Berrangé --- 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 Wed Dec 4 09:36:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 11272569 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 E1352138C for ; Wed, 4 Dec 2019 09:42:18 +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 743B520637 for ; Wed, 4 Dec 2019 09:42:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="hlh/5rYe" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 743B520637 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]:36248 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icRAn-00011Q-CM for patchwork-qemu-devel@patchwork.kernel.org; Wed, 04 Dec 2019 04:42:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38550) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icR5W-0007CR-JP for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icR5F-00009F-4e for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:35 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:54983 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 1icR5E-0008MN-VN for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575452189; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to: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=hlh/5rYeW1fu6GWAw/9Nl/HGZlilHT69xd/ganiQl3ZoN31a6ZjnkeAftecvzndGWASfE+ k5sE41Q1Kar6GTqMEAYfxN1Y57ZDHhjPnH2ZGqw8ORS6RpRCQYobn6OOQvcKBMDCBwYsJ+ l1YJD1v/gbLwF2heZVXePagyYVZyv/M= 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-276-fgS3jZSAOpC5LeaTSeIrqg-1; Wed, 04 Dec 2019 04:36:28 -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 3EC7EDC21 for ; Wed, 4 Dec 2019 09:36:27 +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 0F5031001B09 for ; Wed, 4 Dec 2019 09:36:27 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8EE5411366D1; Wed, 4 Dec 2019 10:36:25 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 04/18] tests: Clean up initialization of Error *err variables Date: Wed, 4 Dec 2019 10:36:11 +0100 Message-Id: <20191204093625.14836-5-armbru@redhat.com> In-Reply-To: <20191204093625.14836-1-armbru@redhat.com> References: <20191204093625.14836-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: fgS3jZSAOpC5LeaTSeIrqg-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: , 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: Eric Blake Reviewed-by: Philippe Mathieu-Daudé --- 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 Wed Dec 4 09:36:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 11272755 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 09D70930 for ; Wed, 4 Dec 2019 11:09:36 +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 99B44206DB for ; Wed, 4 Dec 2019 11:09:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="JMh31jnB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 99B44206DB 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]:36904 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icSXG-0003sl-NN for patchwork-qemu-devel@patchwork.kernel.org; Wed, 04 Dec 2019 06:09:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39016) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icR5Z-0007G6-H2 for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icR5H-0000Hv-Gm for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:46 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:21013 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 1icR5G-0008SZ-BB for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575452190; 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=ck8YC4RtctXQY4XvFDhEnQzwtpi+SeKk9po2VZb4n6E=; b=JMh31jnB4yrx8eUAhiDIdRLS3caH9BCaPxoYW1rRYu+RqA1Ye3aczEVJXUr+c2ath3IxAI lEEeNlers+xV95OvKD4VZPHvTZM7ADnnDm/x2ut7XiDsHOChKJND9zblLyWju1juCdCbcF dTq1zfg83eAkwgxWMjfCbIsMM/nkKEw= 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-286-eLUV5_UrMtuHeT-s4l1ing-1; Wed, 04 Dec 2019 04:36:29 -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 A7BD418543A2 for ; Wed, 4 Dec 2019 09:36:28 +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 7294A19C68; Wed, 4 Dec 2019 09:36:28 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9243111366D5; Wed, 4 Dec 2019 10:36:25 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 05/18] exec: Fix file_ram_alloc() error API violations Date: Wed, 4 Dec 2019 10:36:12 +0100 Message-Id: <20191204093625.14836-6-armbru@redhat.com> In-Reply-To: <20191204093625.14836-1-armbru@redhat.com> References: <20191204093625.14836-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: eLUV5_UrMtuHeT-s4l1ing-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 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). Introduced in commit 056b68af77 "fix qemu exit on memory hotplug when allocation fails at prealloc time". No caller actually passes null. Fix anyway: splice in a local Error *err, and error_propagate(). Cc: Igor Mammedov Signed-off-by: Markus Armbruster Reviewed-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daudé --- 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 Wed Dec 4 09:36:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 11272643 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 4459D14B7 for ; Wed, 4 Dec 2019 09:54: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 18654206DB for ; Wed, 4 Dec 2019 09:54:13 +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="EEP3peea" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 18654206DB 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]:36324 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icRMI-0005Fl-Aw for patchwork-qemu-devel@patchwork.kernel.org; Wed, 04 Dec 2019 04:54:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38697) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icR5Q-0007De-UK for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icR5J-0000S0-N8 for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:39 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:59931 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 1icR5J-00009j-Hy for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575452193; 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=eNZoyFYgA/aKwuSgWEKLFPIR/VOAmutzfJxKqf7RMFw=; b=EEP3peeavoa68rI6rilk0oqtoSDQG2UAABAOhpAkhFv3kIAb0+uLhPe5G4ohC9FCufd8gG qd/+2RjzHwugkhGyDJHefXE2mSRLkiw9Ce7EKH5x4TBbv/6RNtvBZ9Meqqg61sv7HYJpDe TifFDPeMBN4dt7FlqiWUcj68RLMuMhU= 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-184-gNVdFu32OQGLAmDUoyTh7g-1; Wed, 04 Dec 2019 04:36:32 -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 30CFC18543A1 for ; Wed, 4 Dec 2019 09:36:31 +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 721F65D6AE; Wed, 4 Dec 2019 09:36:28 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9586C11366DB; Wed, 4 Dec 2019 10:36:25 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 06/18] hw/acpi: Fix legacy CPU plug error API violations Date: Wed, 4 Dec 2019 10:36:13 +0100 Message-Id: <20191204093625.14836-7-armbru@redhat.com> In-Reply-To: <20191204093625.14836-1-armbru@redhat.com> References: <20191204093625.14836-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: gNVdFu32OQGLAmDUoyTh7g-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: Igor Mammedov , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" legacy_acpi_cpu_plug_cb() dereferences @errp when acpi_set_cpu_present_bit() fails. That's wrong; see the big comment in error.h. Introduced in commit cc43364de7 "acpi/cpu-hotplug: introduce helper function to keep bit setting in one place". No caller actually passes null, and acpi_set_cpu_present_bit() can't actually fail. Fix anyway: drop acpi_set_cpu_present_bit()'s @errp parameter. Cc: "Michael S. Tsirkin" Cc: Igor Mammedov Signed-off-by: Markus Armbruster Reviewed-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin --- 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 Wed Dec 4 09:36:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 11272719 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 74837109A for ; Wed, 4 Dec 2019 10:33:19 +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 4900C20661 for ; Wed, 4 Dec 2019 10:33:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="FPNoEvEI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4900C20661 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]:36586 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icRy9-0003b7-Fd for patchwork-qemu-devel@patchwork.kernel.org; Wed, 04 Dec 2019 05:33:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38640) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icR5T-0007DC-NM for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icR5I-0000MB-Hk for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:38 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:56174 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 1icR5H-0008RY-8E for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575452190; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qt7qBgRXYhoBRK/lPeVpvCp1AuGz4zh1UbVQfAOPcQ0=; b=FPNoEvEINRbcugiawStgrMnyaTfM642xzzc03DtKq4JfIP38pEI7w8c3IxNdfXs7CYyQhS KdHQMw9uQxisoY9gcTDOwKDJZSCV5tDsl3K7HJlHL2yb3Mi1ufFFfw28IQVaigkxrk+oCo G2MMAddOib/w0jHpusIt/6C2+Rcs0XM= 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-298-x70HgSxxMCC-9t5ZNuCpoA-1; Wed, 04 Dec 2019 04:36:29 -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 A367B100550E for ; Wed, 4 Dec 2019 09:36:28 +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 73A2A5D6B7 for ; Wed, 4 Dec 2019 09:36:28 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 98B5311366DF; Wed, 4 Dec 2019 10:36:25 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 07/18] hw/core: Fix fit_load_fdt() error handling violations Date: Wed, 4 Dec 2019 10:36:14 +0100 Message-Id: <20191204093625.14836-8-armbru@redhat.com> In-Reply-To: <20191204093625.14836-1-armbru@redhat.com> References: <20191204093625.14836-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: x70HgSxxMCC-9t5ZNuCpoA-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: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" fit_load_fdt() passes @errp to fit_image_addr(), then recovers from ENOENT failures. Passing @errp is wrong, because it works only as long as @errp is neither @error_fatal nor @error_abort. Messed up in commit 3eb99edb48 "loader-fit: Wean off error_printf()". No caller actually passes such values. Fix anyway: splice in a local Error *err, and error_propagate(). Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daudé --- 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 Wed Dec 4 09:36:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 11272713 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 CA606109A for ; Wed, 4 Dec 2019 10:29: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 953DB206DB for ; Wed, 4 Dec 2019 10:29:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="FoI+JLqn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 953DB206DB 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]:36552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icRuB-0001xI-PC for patchwork-qemu-devel@patchwork.kernel.org; Wed, 04 Dec 2019 05:29:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39007) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icR5W-0007G1-DL for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icR5K-0000W5-My for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:46 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:46756 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 1icR5K-00008m-Hk for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575452192; 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=0bvQfoeL+pOk808cYwQqixdYAIeBL4wm+BDa+63MsU8=; b=FoI+JLqnthJ4nND9ryffaG/b5wsy8guCQjNcp/QwAuKRfpapwtubBKhvz8leeZ60vdj3ds 6Iq0lj+gelbWEvoZRzi2N4UYnLSf4K4KeTTsAA950R2iOcEKjzcSAzbk3+5akru8bqY7rW 7vRLvVLBuDZ+6zSrvX8mJYOVtynIC10= 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-286-CEzWJV9kPje4pvNO4jMHig-1; Wed, 04 Dec 2019 04:36:29 -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 AB633107ACC7; Wed, 4 Dec 2019 09:36:28 +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 7A2B469184; Wed, 4 Dec 2019 09:36:28 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9BFC711366E6; Wed, 4 Dec 2019 10:36:25 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 08/18] hw/ipmi: Fix realize() error API violations Date: Wed, 4 Dec 2019 10:36:15 +0100 Message-Id: <20191204093625.14836-9-armbru@redhat.com> In-Reply-To: <20191204093625.14836-1-armbru@redhat.com> References: <20191204093625.14836-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: CEzWJV9kPje4pvNO4jMHig-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: Corey Minyard 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() dereference @errp when IPMIInterfaceClass method init() fails. That's wrong; see the big comment in error.h. Introduced 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". No caller actually passes null. Fix anyway: splice in a local Error *err, and error_propagate(). 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 Wed Dec 4 09:36:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 11272681 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 CDDE013A4 for ; Wed, 4 Dec 2019 10:02:12 +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 970B72073B for ; Wed, 4 Dec 2019 10:02:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="EkkTPvNB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 970B72073B 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]:36386 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icRU1-00082q-Ov for patchwork-qemu-devel@patchwork.kernel.org; Wed, 04 Dec 2019 05:02:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38556) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icR5O-0007CT-L4 for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icR5G-0000F3-K3 for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:36 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:32763 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 1icR5G-0008Sd-Fp for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575452190; 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=wnj3Sj68Rnwm5t5oQgKpqk1Jaf8yn00PjmYAUZD4nCw=; b=EkkTPvNB4vUzFFhfuBFk74gRzTm/Tc6+NY5OjafbzDQBLqkJC8iXTVvPIfJ9C9YomYCYiK HgXcKeYg0QtC/xd3nXcK7QOx9/2StBYev3pwK+8RxuCAEali72AIefTPd1RLR+pDFFHydQ fkKn+rbG+KHohNRaww4cveTML7mbYNo= 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-380-d68Brm6NMBWc3rtNZ6UJcg-1; Wed, 04 Dec 2019 04:36:29 -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 A5899800D5B; Wed, 4 Dec 2019 09:36:28 +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 770BF600CD; Wed, 4 Dec 2019 09:36:28 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9F26A11366EC; Wed, 4 Dec 2019 10:36:25 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 09/18] qga: Fix guest-get-fsinfo error API violations Date: Wed, 4 Dec 2019 10:36:16 +0100 Message-Id: <20191204093625.14836-10-armbru@redhat.com> In-Reply-To: <20191204093625.14836-1-armbru@redhat.com> References: <20191204093625.14836-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: d68Brm6NMBWc3rtNZ6UJcg-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: Michael Roth Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" build_guest_fsinfo_for_virtual_device() dereferences @errp when build_guest_fsinfo_for_device() fails. That's wrong; see the big comment in error.h. Introduced in commit 46d4c5723e "qga: Add guest-get-fsinfo command". No caller actually passes null. Fix anyway: splice in a local Error *err, and error_propagate(). Cc: Michael Roth Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daudé --- 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 Wed Dec 4 09:36:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 11272709 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 366A7109A for ; Wed, 4 Dec 2019 10:22: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 0A60A206DB for ; Wed, 4 Dec 2019 10:22:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="d8b4wE+h" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0A60A206DB 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]:36516 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icRna-0007g4-4U for patchwork-qemu-devel@patchwork.kernel.org; Wed, 04 Dec 2019 05:22:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38825) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icR5T-0007El-8q for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icR5M-0000bA-4z for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:43 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:35094 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 1icR5L-0000Ie-W5 for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575452195; 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=Td6VxE5zTmUsHVwy0M3hGHsHlUZ8X6ahEXJQ6lgxe2c=; b=d8b4wE+hq7Y3Hrnu3CD9qxjovRlBhQ3kJHf2N0uxDFxEyrLm6p+G0x46kiaBHsVdGy+uBq 5zsY2Wv8e4RuS6qw9Syds7i1HvHcXg80FuBKqDfrJ417/AsqFDAhHzOvLfXuGVbRAsOfyh 7PA7qP3QS1nfhF5F5EMqJN0Y4nXHRL8= 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-134-O3QRq4KFMOqawDMg_zAnmA-1; Wed, 04 Dec 2019 04:36:34 -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 77357DC20 for ; Wed, 4 Dec 2019 09:36:33 +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 796FA5DA60; Wed, 4 Dec 2019 09:36:28 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A250911366F1; Wed, 4 Dec 2019 10:36:25 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 10/18] memory-device: Fix memory pre-plug error API violations Date: Wed, 4 Dec 2019 10:36:17 +0100 Message-Id: <20191204093625.14836-11-armbru@redhat.com> In-Reply-To: <20191204093625.14836-1-armbru@redhat.com> References: <20191204093625.14836-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: O3QRq4KFMOqawDMg_zAnmA-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: David Hildenbrand Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" memory_device_get_free_addr() dereferences @errp when memory_device_check_addable() fails. That's wrong; see the big comment in error.h. Introduced in commit 1b6d6af21b "pc-dimm: factor out capacity and slot checks into MemoryDevice". No caller actually passes null. Fix anyway: splice in a local Error *err, and error_propagate(). 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 Wed Dec 4 09:36:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 11272731 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 BD1BC138D for ; Wed, 4 Dec 2019 10:45:36 +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 8D258207DD for ; Wed, 4 Dec 2019 10:45:36 +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="fAbN+Wu8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8D258207DD 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]:36694 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icSA1-00032I-O4 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 04 Dec 2019 05:45:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38920) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icR5W-0007FB-R0 for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icR5L-0000Yg-E8 for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:42 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:33316 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 1icR5L-0000BO-9X for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575452193; 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=xptOCNnsIHKHFrFX5zqteF/m5AlNBeqPE8IAUUchUhE=; b=fAbN+Wu89nVoghJF+/Q2v8NrzxCZNVAGN9rVUmmRLQf6F69O3BV9IuBkfpyw0zPnXlxAf8 laP3u7mPppUy5FIQBKEFWh2U4/Wjtac6K1oNZlIwBOnZkp8N7bxImP6fpUh9nFuxDsybol elWCD0VAfN6wu35lB/VgsG2Lz9JIRtM= 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-106-agi402gYNLGVclUIkciM9A-1; Wed, 04 Dec 2019 04:36:31 -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 240F7800D54 for ; Wed, 4 Dec 2019 09:36:31 +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 813511001925; Wed, 4 Dec 2019 09:36:28 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A58C511366F2; Wed, 4 Dec 2019 10:36:25 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 11/18] s390x/event-facility: Fix realize() error API violations Date: Wed, 4 Dec 2019 10:36:18 +0100 Message-Id: <20191204093625.14836-12-armbru@redhat.com> In-Reply-To: <20191204093625.14836-1-armbru@redhat.com> References: <20191204093625.14836-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: agi402gYNLGVclUIkciM9A-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 , David Hildenbrand Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" sclp_events_bus_realize() dereferences @errp when object_property_set_bool() fails. That's wrong; see the big comment in error.h. Introduced in commit f6102c329c "s390/sclp: rework sclp event facility initialization + device realization". No caller actually passes null. Fix anyway: splice in a local Error *err, and error_propagate(). 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 Wed Dec 4 09:36:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 11272717 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 4CA1B138C for ; Wed, 4 Dec 2019 10:33:17 +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 2081B20661 for ; Wed, 4 Dec 2019 10:33:17 +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="eksR6aFl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2081B20661 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]:36580 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icRy5-0003VI-AC for patchwork-qemu-devel@patchwork.kernel.org; Wed, 04 Dec 2019 05:33:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39144) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icR5l-0007IO-1k for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:37:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icR5P-0000mM-8l for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:53 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:49190 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 1icR5P-0000WT-3V for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575452198; 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=1cWosWeT2TZOK6LwSZ56SM2lpIU6/+dPaDq6QV9nsFw=; b=eksR6aFloddx596T4v8SkYSEJCK7XZC1dMAgiNnmrjAtByPZ+RXu9RC8XQiMM0B48f5U4W o+hFFhjLKtJqDAtAh5Sy1Rj/vAcoHoppULR6+LUHLXsxWOObuCVNJpV8N63874kkJNlga7 qLLuPRMhDiI+hLE7pMDR0LmVIJdztg8= 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-62-KP3NdkBDO0Kp0ZNRA6CUHA-1; Wed, 04 Dec 2019 04:36:32 -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 A024BDC21 for ; Wed, 4 Dec 2019 09:36:31 +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 80BCD19C69; Wed, 4 Dec 2019 09:36:28 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A8BE411366F3; Wed, 4 Dec 2019 10:36:25 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 12/18] s390x/cpumodel: Fix feature property error API violations Date: Wed, 4 Dec 2019 10:36:19 +0100 Message-Id: <20191204093625.14836-13-armbru@redhat.com> In-Reply-To: <20191204093625.14836-1-armbru@redhat.com> References: <20191204093625.14836-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: KP3NdkBDO0Kp0ZNRA6CUHA-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 , 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() dereference @errp when the visitor fails. That's wrong; see the big comment in error.h. Introduced in commit 0754f60429 "s390x/cpumodel: expose features and feature groups as properties". No caller actually passes null. Fix anyway: splice in a local Error *err, and error_propagate(). 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 Wed Dec 4 09:36: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: 11272711 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 A6326109A for ; Wed, 4 Dec 2019 10:25:07 +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 7A290206DB for ; Wed, 4 Dec 2019 10:25:05 +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="RP07omrE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7A290206DB 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]:36528 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icRqC-0000NY-Ve for patchwork-qemu-devel@patchwork.kernel.org; Wed, 04 Dec 2019 05:25:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38834) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icR5W-0007Ep-E7 for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icR5M-0000bs-AY for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:43 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:23553 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 1icR5M-0000Bn-5W for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575452193; 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=P4RnQPlmqBzcfDiHCZteURy6me1QA9GlGCFi3SGCF9k=; b=RP07omrE8eTjFJ8BiPEro39TwdE0xy6fil4g2mcDYetnvXgVJDYe6WwNfbxQgiCmJlxaNb jbPAW5Qn69PCRB7XksyvfvnrxzFxS+hfV9s7bg+NWaMpWXhBTTnYcka0u/g0B84Os/2o0E tynRLlTyIOZi7H2XiLVVdJcm5xFjArg= 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-350--IX65pduNGO0Rz91j0-3TA-1; Wed, 04 Dec 2019 04:36:32 -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 9FE6F800D5B for ; Wed, 4 Dec 2019 09:36:31 +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 DDF1219C68; Wed, 4 Dec 2019 09:36:29 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id AC0F211366F7; Wed, 4 Dec 2019 10:36:25 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 13/18] s390x/cpumodel: Fix realize() error API violations Date: Wed, 4 Dec 2019 10:36:20 +0100 Message-Id: <20191204093625.14836-14-armbru@redhat.com> In-Reply-To: <20191204093625.14836-1-armbru@redhat.com> References: <20191204093625.14836-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: -IX65pduNGO0Rz91j0-3TA-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 , David Hildenbrand Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" get_max_cpu_model() dereferences @errp when kvm_s390_get_host_cpu_model() fails, apply_cpu_model() dereferences it when kvm_s390_apply_cpu_model() fails, and s390_realize_cpu_model() dereferences it when get_max_cpu_model() or check_compatibility() fail. That's wrong; see the big comment in error.h. All three introduced in commit 80560137cf "s390x/cpumodel: check and apply the CPU model". No caller actually passes null. Fix anyway: splice in a local Error *err, and error_propagate(). 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 Wed Dec 4 09:36: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: 11272729 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 BADF9138C for ; Wed, 4 Dec 2019 10:41:22 +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 8FF60207DD for ; Wed, 4 Dec 2019 10:41:22 +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="EXpb1r+U" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8FF60207DD 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]:36658 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icS5x-0000NF-FS for patchwork-qemu-devel@patchwork.kernel.org; Wed, 04 Dec 2019 05:41:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39169) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icR5n-0007J8-Sl for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:37:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icR5L-0000Xu-3C for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:50 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:42314 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 1icR5K-0000MH-UE for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575452196; 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=NE3kP/DOAuh+KztePlu2TgOR4p2JwUK9MqY4o9RapzI=; b=EXpb1r+UCi/0veQSmNOH/NBC6wWOcY6iDplauI8P2EjsQC82Zs/tGviwQKqFcHrl26QO6p EEl+O+BeJ/5xbrGJle33k9y2Oo7QABFH2/car++e5PKIYSwy3TBN1eMqhX+565XW4t24Ha bA52y/Kjjp0ydXBoRu2hpTjy0FUkfFY= 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-146-ARweqmouMWCT93hHyKeCjA-1; Wed, 04 Dec 2019 04:36:35 -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 7FFEF801E70 for ; Wed, 4 Dec 2019 09:36:34 +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 DD4475D6B7; Wed, 4 Dec 2019 09:36:29 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id AF4DD113639C; Wed, 4 Dec 2019 10:36:25 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 14/18] s390x/cpumodel: Fix query-cpu-model-FOO error API violations Date: Wed, 4 Dec 2019 10:36:21 +0100 Message-Id: <20191204093625.14836-15-armbru@redhat.com> In-Reply-To: <20191204093625.14836-1-armbru@redhat.com> References: <20191204093625.14836-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: ARweqmouMWCT93hHyKeCjA-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 , 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 dereferences @errp when the visitor or the QOM setter fails. That's wrong; see the big comment in error.h. Introduced in commit 137974cea3 's390x/cpumodel: implement QMP interface "query-cpu-model-expansion"'. Its three callers have the same issue. Introduced in commit 4e82ef0502 's390x/cpumodel: implement QMP interface "query-cpu-model-comparison"' and commit f1a47d08ef 's390x/cpumodel: implement QMP interface "query-cpu-model-baseline"'. No caller actually passes null. Fix anyway: splice in a local Error *err, and error_propagate(). 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 Wed Dec 4 09:36: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: 11272721 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 07395109A for ; Wed, 4 Dec 2019 10:35:05 +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 CFFAF2073C for ; Wed, 4 Dec 2019 10:35:04 +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="Tk0e5Kap" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CFFAF2073C 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]:36592 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icRzq-0004ZZ-SA for patchwork-qemu-devel@patchwork.kernel.org; Wed, 04 Dec 2019 05:35:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38718) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icR5g-0007Ds-FA for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:37:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icR5J-0000QU-Dl for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:39 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:38344 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 1icR5J-0000Fy-6U for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575452194; 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=aryLVqd6aYkbTJUrzzMomPXJEC6cSDvsxwWZWhAo3dg=; b=Tk0e5KapxgBxpVekpRBpaoEkFRUXin7VUe/1Pb14ZhJkkJFmWIZRtvsd8uNB2KUol/TKJv rEaGIx12xxfw7sHT9Fcvo/ibVW6CUcHw03CUxHf4NPyRh9q/gh6XgTpWyVbZa331yAREZq czTM7slq6++Kmmuc6+f7RKo3oQtasKM= 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-382-dpMq_yWmNpm6VQh-vTUPNg-1; Wed, 04 Dec 2019 04:36:33 -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 C79B310054E3 for ; Wed, 4 Dec 2019 09:36:32 +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 DF17F5C1B5; Wed, 4 Dec 2019 09:36:29 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id B28D41135A56; Wed, 4 Dec 2019 10:36:25 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 15/18] s390x/cpumodel: Fix query-cpu-definitions error API violations Date: Wed, 4 Dec 2019 10:36:22 +0100 Message-Id: <20191204093625.14836-16-armbru@redhat.com> In-Reply-To: <20191204093625.14836-1-armbru@redhat.com> References: <20191204093625.14836-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: dpMq_yWmNpm6VQh-vTUPNg-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 , David Hildenbrand Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" qmp_query_cpu_definitions() passes @errp to get_max_cpu_model(), then frees any error it gets back. This effectively ignores errors. Dereferencing @errp is wrong; see the big comment in error.h. Passing @errp is also wrong, because it works only as long as @errp is neither @error_fatal nor @error_abort. Introduced in commit 38cba1f4d8 "s390x: return unavailable features via query-cpu-definitions". No caller actually passes such @errp values. Fix anyway: simply pass NULL to get_max_cpu_model(). 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 Wed Dec 4 09:36: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: 11272741 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 8DB09138C for ; Wed, 4 Dec 2019 10:56:46 +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 632D120803 for ; Wed, 4 Dec 2019 10:56:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="f8/GRM4/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 632D120803 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]:36754 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icSKp-0007rh-Ic for patchwork-qemu-devel@patchwork.kernel.org; Wed, 04 Dec 2019 05:56:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38943) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icR5X-0007FF-9N for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icR5M-0000dt-Pj for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:45 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:59703 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 1icR5L-0000HA-KZ for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575452195; 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=Oa5WE/nKsyDG9iac2CyuX+6S97udqs/iRIMLUaH3FD8=; b=f8/GRM4/bGYo7r16x7J9KUEXBql08Yn2Vu04XpZJCxn5IJ5j5EkBNpPbEuty7boVqJf/zo OXc9Xf3MVhNFqXe/4GePNnuVdopJzNkstUe76TIxSL43ffGAfc8U1kCJAHAbBYrJ7ZzITQ OajD97f+VXPDPee8PvopptfqOZdcCkM= 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-96-7KsMvBykM2miTJKOptcVcg-1; Wed, 04 Dec 2019 04:36:33 -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 0F444107ACC4 for ; Wed, 4 Dec 2019 09:36:33 +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 E048519C6A; Wed, 4 Dec 2019 09:36:29 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id B5C731135A59; Wed, 4 Dec 2019 10:36:25 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 16/18] error: Clean up unusual names of Error * variables Date: Wed, 4 Dec 2019 10:36:23 +0100 Message-Id: <20191204093625.14836-17-armbru@redhat.com> In-Reply-To: <20191204093625.14836-1-armbru@redhat.com> References: <20191204093625.14836-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: 7KsMvBykM2miTJKOptcVcg-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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= 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 Wed Dec 4 09:36:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 11272703 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 D713D109A for ; Wed, 4 Dec 2019 10:18:14 +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 9FCFD20675 for ; Wed, 4 Dec 2019 10:18:14 +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="TB3ydu66" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9FCFD20675 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]:36488 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icRjY-0005ks-Q0 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 04 Dec 2019 05:18:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38654) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icR5e-0007DF-VO for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:37:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icR5H-0000K0-TZ for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:38 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:38437 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 1icR5H-00005y-N8 for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575452192; 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=14FWoiUPuC2dvHRmr4gxNehnlsWm5XKtEJ5hCDY2NmI=; b=TB3ydu66pS236gvip0dQBL36Iqe3T3eKNT9Eab7ZT4amZJYwRvJQ7s4aAE+tJLvaWW3tG7 YeJlnfuqbe8Ndo3NnK1eUoO708WsZvyLGi7u2yzWWtVvTUdWU4bOeVLK02dWVQnBGo7FaE qnsu71u5VZDDFi15O/oCnQz3qep3OAE= 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-224-LWMN6jSYNcCu74znihV8hw-1; Wed, 04 Dec 2019 04:36:31 -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 282B118543A0; Wed, 4 Dec 2019 09:36:30 +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 E5B715D6BB; Wed, 4 Dec 2019 09:36:29 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id B8FA41135A5A; Wed, 4 Dec 2019 10:36:25 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 17/18] hw/intc/s390: Simplify error handling in kvm_s390_flic_realize() Date: Wed, 4 Dec 2019 10:36:24 +0100 Message-Id: <20191204093625.14836-18-armbru@redhat.com> In-Reply-To: <20191204093625.14836-1-armbru@redhat.com> References: <20191204093625.14836-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: LWMN6jSYNcCu74znihV8hw-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 , 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 Wed Dec 4 09:36:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 11272723 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 A9D97109A for ; Wed, 4 Dec 2019 10:37: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 3A6282068E for ; Wed, 4 Dec 2019 10:37: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="AzZgIzKa" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3A6282068E 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]:36614 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icS2C-0006HX-J4 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 04 Dec 2019 05:37:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39061) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icR5a-0007GO-Ee for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icR5K-0000U2-7Y for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:48 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:25634 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 1icR5K-00007m-2h for qemu-devel@nongnu.org; Wed, 04 Dec 2019 04:36:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575452192; 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=VcQfbWOSujNj2P6dQg61amOzZoiTXvVBDPQOllhUYpQ=; b=AzZgIzKa9xKtrjP284tvJgTPZrYYFU5VHoCUIgD7gxBwqHNaaMR1VbUWEFL/3EUG/2eNja lw43jOMVJm3PvlW1tdHHPPIAM0VSyxNlYAhaDSW7Ypgg+/yYlgRyGR/aUpWcfTVAGbLsHH ztJFEKVRjzBhAjneBscDs3SlY/K8q+k= 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-162-JAQm_k9SOUSeBuStts26fQ-1; Wed, 04 Dec 2019 04:36:30 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 277BF107ACC4 for ; Wed, 4 Dec 2019 09:36:30 +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 E9BA260C63; Wed, 4 Dec 2019 09:36:29 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id BC27E1135A63; Wed, 4 Dec 2019 10:36:25 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 18/18] tests-blockjob: Use error_free_or_abort() Date: Wed, 4 Dec 2019 10:36:25 +0100 Message-Id: <20191204093625.14836-19-armbru@redhat.com> In-Reply-To: <20191204093625.14836-1-armbru@redhat.com> References: <20191204093625.14836-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: JAQm_k9SOUSeBuStts26fQ-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: , 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;