From nobody Thu May 16 06:18:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1710127531; cv=none; d=zohomail.com; s=zohoarc; b=EincYhGppS3fMJH1NSmfwegcNqP5XgHi5hxNcvopy371OfJPKOCTJJjnL6TX4+LRG0DbH9sFt29vVKZOgBo1VKtIHgFyUXKRrqxKBNW/xFqwzLnNSk/yEHMWSpw3DKrG3ez/EgLqCQCxDEZsbjkheUctqJ7KwuqKi+ibvQqFLkI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710127531; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=jqRL8PASmE94GgjKmNjEHRgISNVd4Ym+zSe+C8x68bU=; b=U7xalihzRkrRTYl4a1AkFSdiuqFdXjvXBdiwm2XFClJvIkhlrX0Wl04rTGgg5JC7vakvI13PyDSPp+0xiHNnpbYgrhYAcOfBNDCTLGrBUDuBTGqIU3JsyqZGKVwm/peWeAPwf74VUz1+TYvPonfHO4bYDLiUMcd1vpnxVWB0Fcs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710127530949329.9215350433427; Sun, 10 Mar 2024 20:25:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjWHS-0005Xp-3F; Sun, 10 Mar 2024 23:24:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWHP-0005W8-E3; Sun, 10 Mar 2024 23:24:47 -0400 Received: from mgamail.intel.com ([198.175.65.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWHN-0007qJ-DL; Sun, 10 Mar 2024 23:24:47 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2024 20:24:43 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa003.fm.intel.com with ESMTP; 10 Mar 2024 20:24:42 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710127485; x=1741663485; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9u2qpUQw+97M2ytR4D9PH0ERtHP9EM+bxi7PUz1J0MM=; b=f+5F5Oh0AUwUKO3ZQFnhLZRafbXONiq4LZ7t91ncgJXDQFeujqgaUtCZ C8O2k3loJlSr86qOk9EjZqd2pfKV2mcokdlcUAhTiNiw/WZcaZbYgQssN Wdtd0JxQTU1F84hki38zLPApLk1MU482a2s/Hb46TTW1AzAPA65sud+l8 pRsKldQP7BK8jL8Wm3qJ6QgaJnOf1h8UzeUaWjoGGb9Gpxq5H8N/IebZX Lut5YmP9PMUv4/PRTqJ+PxWYRmAeWzjwa8EsLJbBZzLwn6W2GlNO4YcrH cdvA7YtIpD7B5t/xQQ/alEGAcugpnKfZOeoB7XgivDv7yAjfMLK6pjzTP A==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="22229576" X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="22229576" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="15593711" From: Zhao Liu To: Thomas Huth , Markus Armbruster , Michael Roth , Michael Tokarev , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Zhao Liu Subject: [PATCH v2 01/29] error: Add error_vprepend() in comment of ERRP_GUARD() rules Date: Mon, 11 Mar 2024 11:37:54 +0800 Message-Id: <20240311033822.3142585-2-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> References: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.10; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.945, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1710127533448100001 Content-Type: text/plain; charset="utf-8" From: Zhao Liu The error_vprepend() should use ERRP_GUARD() just as the documentation of ERRP_GUARD() says: > It must be used when the function dereferences @errp or passes > @errp to error_prepend(), error_vprepend(), or error_append_hint(). Considering that error_vprepend() is also an API provided in error.h, it is necessary to add it to the description of the rules for using ERRP_GUARD(). Cc: Markus Armbruster Cc: Michael Roth Signed-off-by: Zhao Liu Reviewed-by: Markus Armbruster --- v2: Add a comma after error_vprepend(). (Markus) --- include/qapi/error.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/qapi/error.h b/include/qapi/error.h index f21a231bb1a6..71f8fb2c50ee 100644 --- a/include/qapi/error.h +++ b/include/qapi/error.h @@ -207,7 +207,7 @@ * * Without ERRP_GUARD(), use of the @errp parameter is restricted: * - It must not be dereferenced, because it may be null. - * - It should not be passed to error_prepend() or + * - It should not be passed to error_prepend(), error_vprepend(), or * error_append_hint(), because that doesn't work with &error_fatal. * ERRP_GUARD() lifts these restrictions. * --=20 2.34.1 From nobody Thu May 16 06:18:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1710127554; cv=none; d=zohomail.com; s=zohoarc; b=Q+jO9RQPzFWE2r9yXQcQuKQtC4OZlSdwV1vI40O8TCPI5GOuv9WMRMzrcJyTYLxrkY3EnolNSEvqtUuUlHLtFaJkSIAfg4gwAeN1WrVjT0iuHL13Qa2/D0C05x8izKhZe0QYJfzrgJUrmoFZbq/yI6+Sw6gWuzMK7PuVlDJIqso= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710127554; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NGskcu1+BTOqGGNQoxKIHv4fqIu0OUAisUF+74ge5YQ=; b=FzlRDWrtH58Ro1rTyIyBF/iJB2lUiejt1Phq8OIiXCthFhnrzHUnmTt4KPxGeFAOcxI5ZmjGcoAbeEmZiHDvBClCdkmdSsdLrLkNL/rECWNNpy1xw0JiFwuRW89i1NwgHN/+AKDnraY0QTpRu/ixvb5aMfHss552wg+/9DDGy1M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710127554111769.1144484136538; Sun, 10 Mar 2024 20:25:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjWHT-0005YQ-LG; Sun, 10 Mar 2024 23:24:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWHR-0005XP-J8; Sun, 10 Mar 2024 23:24:49 -0400 Received: from mgamail.intel.com ([198.175.65.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWHQ-0007qJ-24; Sun, 10 Mar 2024 23:24:49 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2024 20:24:46 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa003.fm.intel.com with ESMTP; 10 Mar 2024 20:24:44 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710127488; x=1741663488; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Ku/zdz8Cve9RNOFOIfrMmxPdZkjkIFoafU6wceTFb3Q=; b=Z9IMVOIn7eZBNdVUO8W2jCM9Hbe79eSb27gCwXNUxPB1Y51XTIvBUKh4 K8/N4ZwiHibzVPHb1PTIrYqdFFB8tFU+svkCpu32lRaz/GgdsvEVU+F8v oUGoTlSZbTg04ZyVlB36hcT3xoNAczw4AGGm1Sfz92y/2QrIaQMMK33tN SBwn/34vqhrc3vjtHxFrJdcaQy0+6ZAAmh5egqx5bAmSZCyWPG9lO0ygH tERAdOLeMiJUMA5pFv2aGwxoOcBqFph9ZA3OmISs7lWOIisJbVdD9ivHY 0Lg4nuvcbKdhUwXFvfEixPyDI6a22Gax57XEty3cWTrT2lW3NKmo5sKnd A==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="22229581" X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="22229581" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="15593716" From: Zhao Liu To: Thomas Huth , Markus Armbruster , Michael Roth , Michael Tokarev , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Zhao Liu , Yi Liu , Eric Auger , Zhenzhong Duan Subject: [PATCH v2 02/29] backends/iommufd: Fix missing ERRP_GUARD() for error_prepend() Date: Mon, 11 Mar 2024 11:37:55 +0800 Message-Id: <20240311033822.3142585-3-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> References: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.10; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.945, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1710127555322100003 Content-Type: text/plain; charset="utf-8" From: Zhao Liu As the comment in qapi/error, passing @errp to error_prepend() requires ERRP_GUARD(): * =3D Why, when and how to use ERRP_GUARD() =3D * * Without ERRP_GUARD(), use of the @errp parameter is restricted: ... * - It should not be passed to error_prepend(), error_vprepend() or * error_append_hint(), because that doesn't work with &error_fatal. * ERRP_GUARD() lifts these restrictions. * * To use ERRP_GUARD(), add it right at the beginning of the function. * @errp can then be used without worrying about the argument being * NULL or &error_fatal. ERRP_GUARD() could avoid the case when @errp is &error_fatal, the user can't see this additional information, because exit() happens in error_setg earlier than information is added [1]. The iommufd_backend_set_fd() passes @errp to error_prepend(), to avoid the above issue, add missing ERRP_GUARD() at the beginning of this function. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: Yi Liu Cc: Eric Auger Cc: Zhenzhong Duan Signed-off-by: Zhao Liu Reviewed-by: Zhenzhong Duan Reviewed-by: Eric Auger --- backends/iommufd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/backends/iommufd.c b/backends/iommufd.c index 1ef683c7b080..62a79fa6b049 100644 --- a/backends/iommufd.c +++ b/backends/iommufd.c @@ -43,6 +43,7 @@ static void iommufd_backend_finalize(Object *obj) =20 static void iommufd_backend_set_fd(Object *obj, const char *str, Error **e= rrp) { + ERRP_GUARD(); IOMMUFDBackend *be =3D IOMMUFD_BACKEND(obj); int fd =3D -1; =20 --=20 2.34.1 From nobody Thu May 16 06:18:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1710127734; cv=none; d=zohomail.com; s=zohoarc; b=MEzBcIwWjj+3A2qhCozw4h7VLacuVA/T7s95ecrIHWcLZKjtim9HaqZCmJoNh5xIEQjaC0YXDojcx6tXq84skBlsezC3g1mWa64j6vdNM6qLWl/IYx5LHZk+eVG9SOgyl7VAkOuNdAu1RkiOWfCA6lG46AAbGmrfig+gXSVlfBw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710127734; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=MeIftjZ4Gm1kx3EthQEVYuo0KvF4oR73cZp3brvL7AM=; b=g6q8E5iRm3X/EduxAOxZwyZqkrv2QeGFYa3nnkc9E+YxtNwpof0nnqKPb1km0dM5kt0L9W3aM6bDElnsjYYp7e6G1FglgG8jBxFfG/xzcBPYRY/l45uHD4DL9292/dyQSpwlIbZeTEgm5xVZrDaB18x4myVZSAJMSKRceZeewDs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710127734679365.21397125725116; Sun, 10 Mar 2024 20:28:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjWHW-0005ZC-VV; Sun, 10 Mar 2024 23:24:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWHV-0005Yo-TL; Sun, 10 Mar 2024 23:24:53 -0400 Received: from mgamail.intel.com ([198.175.65.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWHU-0007rZ-7b; Sun, 10 Mar 2024 23:24:53 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2024 20:24:50 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa003.fm.intel.com with ESMTP; 10 Mar 2024 20:24:47 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710127492; x=1741663492; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Df8TZAiYBeLcQdJvojI1ZKKv4azS1j0SO2PFl2TxogE=; b=K6bM2Kz7eZsM83IaZTznFuzrnP6Mef06H7QopGDVja4iZ9ByPivy0/zA oTp3Qo8PHsp/IOLlvCF5zFeKKGRDd1yfuweB3eQA/bOgmp29JmqwI/lke 6aIsnRZle6pncrPKuA0txUgy5ZbIz0vlhBRL6IynpjXLrxhHxfaMjRpsE vYKZaOXSrOp/uk6rSSH6kSZ9nw5RxlPU3QucGREXrd+gURUCxysSiDUwT dU4AqPewHpS7MkAl2IrSxhg57G5resg2UBV4GUzK32A9cwIiL1GbSAFKh FvNZ7IJDfrASaHyQq/A4gCRbsgR9zWp03M1sJIeSkyCWnG4lcTrx7ZGzn A==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="22229589" X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="22229589" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="15593723" From: Zhao Liu To: Thomas Huth , Markus Armbruster , Michael Roth , Michael Tokarev , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Zhao Liu , Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org, Eric Blake Subject: [PATCH v2 03/29] block: Fix missing ERRP_GUARD() for error_prepend() Date: Mon, 11 Mar 2024 11:37:56 +0800 Message-Id: <20240311033822.3142585-4-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> References: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.10; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.945, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1710127735256100009 Content-Type: text/plain; charset="utf-8" From: Zhao Liu As the comment in qapi/error, passing @errp to error_prepend() requires ERRP_GUARD(): * =3D Why, when and how to use ERRP_GUARD() =3D * * Without ERRP_GUARD(), use of the @errp parameter is restricted: ... * - It should not be passed to error_prepend(), error_vprepend() or * error_append_hint(), because that doesn't work with &error_fatal. * ERRP_GUARD() lifts these restrictions. * * To use ERRP_GUARD(), add it right at the beginning of the function. * @errp can then be used without worrying about the argument being * NULL or &error_fatal. ERRP_GUARD() could avoid the case when @errp is &error_fatal, the user can't see this additional information, because exit() happens in error_setg earlier than information is added [1]. In block.c, there are 4 functions passing @errp to error_prepend() without ERRP_GUARD(): - bdrv_co_create_opts_simple() - parse_json_filename() - bdrv_open_backing_file() - bdrv_append_temp_snapshot() bdrv_co_create_opts_simple(), is an implementation of BlockDriver.bdrv_co_create_opts(). There are too many possible callers to check the impact of this defect; it may or may not be harmless. Thus it is necessary to protect @errp with ERRP_GUARD(). Though the @errp parameters passed to parse_json_filename(), bdrv_open_backing_file() and bdrv_append_temp_snapshot() points to their callers' local_err, to follow the requirement of @errp, also add missing ERRP_GUARD() at their beginning. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: Kevin Wolf Cc: Hanna Reitz Cc: qemu-block@nongnu.org Signed-off-by: Zhao Liu Reviewed-by: Eric Blake --- v2: * Use Markus' sentence to polish commit message. (Markus) * Fix typo. (Eric) --- block.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/block.c b/block.c index 1ed9214f66ed..cf66c767a011 100644 --- a/block.c +++ b/block.c @@ -633,6 +633,7 @@ int coroutine_fn bdrv_co_create_opts_simple(BlockDriver= *drv, QemuOpts *opts, Error **errp) { + ERRP_GUARD(); BlockBackend *blk; QDict *options; int64_t size =3D 0; @@ -1998,6 +1999,7 @@ fail_opts: =20 static QDict *parse_json_filename(const char *filename, Error **errp) { + ERRP_GUARD(); QObject *options_obj; QDict *options; int ret; @@ -3585,6 +3587,7 @@ int bdrv_set_backing_hd(BlockDriverState *bs, BlockDr= iverState *backing_hd, int bdrv_open_backing_file(BlockDriverState *bs, QDict *parent_options, const char *bdref_key, Error **errp) { + ERRP_GUARD(); char *backing_filename =3D NULL; char *bdref_key_dot; const char *reference =3D NULL; @@ -3851,6 +3854,7 @@ static BlockDriverState *bdrv_append_temp_snapshot(Bl= ockDriverState *bs, QDict *snapshot_options, Error **errp) { + ERRP_GUARD(); g_autofree char *tmp_filename =3D NULL; int64_t total_size; QemuOpts *opts =3D NULL; --=20 2.34.1 From nobody Thu May 16 06:18:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1710127531; cv=none; d=zohomail.com; s=zohoarc; b=TchMiW285XCosV/VMkxMQ4XGBh7OPe/i5ieyYFFF9bOOb0dJPD+0WD9nSYN/44hf333vhfJD8OED4OrGBnYdfJKAKWPm5cxrKF63JSk3RBrSJ1UA67z5vh3gk8siN5SNEaidMzqnyrA7oeIGS6UuIC1CuifXMl0QC/Va25IZqxc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710127531; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=s8FReNAm+o03LZi7Y20501hBrvpqtbI+W9xwcX5Rh8o=; b=WMVXb3/Csqe+xtIU21DlqzwKsniy+amTzquUJXcTv+798jN2v7z0E4QurcHmnMf6WQ6hrnw8adP/a3kIoFsvVD49NUotYxyH3YWyv7XPDlhi/gNvHLvWHrbOfr5z2Fkgr/Q4FhSpYV1L8hQD8NtwYjG7RQSib3byx5phbLsu/Z4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710127530983727.6372831795376; Sun, 10 Mar 2024 20:25:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjWHb-0005aN-Tu; Sun, 10 Mar 2024 23:24:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWHY-0005Zm-Ig; Sun, 10 Mar 2024 23:24:56 -0400 Received: from mgamail.intel.com ([198.175.65.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWHW-0007rZ-Vu; Sun, 10 Mar 2024 23:24:56 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2024 20:24:53 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa003.fm.intel.com with ESMTP; 10 Mar 2024 20:24:50 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710127495; x=1741663495; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5dgSOzTTA45itG0zhwcLx2J6Kw1BqasX3E9AuDV3aEc=; b=i7rzigj8ulSjEVKl4jBdVTSK1E2pxGBSjAqEvg4nC1O6iAP8u+QvuVh2 WkbFU0Nm19jD/ZW2Qg1ramCfBzIcEuyzstaIa0Qc38KTBvLDXfWkI68ZC uGx0LLTGCuWXtLmGmFhO9tfLDu3yK4GhNtnc1F7exIy1hmjiHFdJjK+ut p1jCTd+9t1uiV9PurHFtuUG/NVq2PAsO8Y7Wls9XIFMxk0jzy4P2AC9gR h/Jo8nWp6HHogL7F9Dcc3VyXUf36JAmTK3PASgNO71J2cuPiKASOzagNp 8GWW/2gqebM0CnvZzLBzBjqdLTFFoBUhZ21nkpPmt83hIrxB2hOADw+2R Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="22229598" X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="22229598" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="15593732" From: Zhao Liu To: Thomas Huth , Markus Armbruster , Michael Roth , Michael Tokarev , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Zhao Liu , John Snow , Vladimir Sementsov-Ogievskiy , Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org Subject: [PATCH v2 04/29] block/copy-before-write: Fix missing ERRP_GUARD() for error_prepend() Date: Mon, 11 Mar 2024 11:37:57 +0800 Message-Id: <20240311033822.3142585-5-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> References: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.10; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.945, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1710127533451100002 Content-Type: text/plain; charset="utf-8" From: Zhao Liu As the comment in qapi/error, passing @errp to error_prepend() requires ERRP_GUARD(): * =3D Why, when and how to use ERRP_GUARD() =3D * * Without ERRP_GUARD(), use of the @errp parameter is restricted: ... * - It should not be passed to error_prepend(), error_vprepend() or * error_append_hint(), because that doesn't work with &error_fatal. * ERRP_GUARD() lifts these restrictions. * * To use ERRP_GUARD(), add it right at the beginning of the function. * @errp can then be used without worrying about the argument being * NULL or &error_fatal. ERRP_GUARD() could avoid the case when @errp is &error_fatal, the user can't see this additional information, because exit() happens in error_setg earlier than information is added [1]. The cbw_open() passes @errp to error_prepend() without ERRP_GUARD(). Though it is the BlockDriver.bdrv_open() method, and currently its @errp parameter only points to callers' local_err, to follow the requirement of @errp, add missing ERRP_GUARD() at the beginning of this function. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: John Snow Cc: Vladimir Sementsov-Ogievskiy Cc: Kevin Wolf Cc: Hanna Reitz Cc: qemu-block@nongnu.org Signed-off-by: Zhao Liu Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/copy-before-write.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/copy-before-write.c b/block/copy-before-write.c index 0842a1a6dfbe..8aba27a71d6d 100644 --- a/block/copy-before-write.c +++ b/block/copy-before-write.c @@ -407,6 +407,7 @@ out: static int cbw_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { + ERRP_GUARD(); BDRVCopyBeforeWriteState *s =3D bs->opaque; BdrvDirtyBitmap *bitmap =3D NULL; int64_t cluster_size; --=20 2.34.1 From nobody Thu May 16 06:18:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1710127563; cv=none; d=zohomail.com; s=zohoarc; b=XU/XMsTvR/IzA/GDHr9/QePiIKK+mRCxl2F/7UETlfMciVYhke72euf8+BVoCJ8MfCBrNE6Hs3MylkpDzn3PapOZZT7PbfjngHPWsxOGTqMCSIiOfraSYiLPbdFh7+4zQaKaLW9+Xp3pmhnIRZzMg0O5zh2CzJntB0Kjj+yzmHo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710127563; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Rjclg24rqM13uZ5+7lmt/HOmC46CHVWAUEDnWSR+lyA=; b=bHi/XWEerRvqwXm/d/6vbXUIQvrO0voy9p/yI0ijmeBr0jSwp1ezRBigcn33JNKkd+AF4PNjXoAt+HtAWpteEF+RfjHtgDqSme8oJkOSFcduxLl5oX9nIuoXbudGNFM7/vFgt6c7Md9/eA7AgocfYoPQx/XrBkYTkH0LjHIman4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17101275635461020.3587633316107; Sun, 10 Mar 2024 20:26:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjWHh-0005bb-Ts; Sun, 10 Mar 2024 23:25:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWHc-0005al-8m; Sun, 10 Mar 2024 23:25:00 -0400 Received: from mgamail.intel.com ([198.175.65.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWHa-0007rZ-NN; Sun, 10 Mar 2024 23:25:00 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2024 20:24:57 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa003.fm.intel.com with ESMTP; 10 Mar 2024 20:24:54 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710127498; x=1741663498; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Ka71Ek3PnNyeK5aeuQsU7hwBRQ4pWyZd0PGtwm5w0L0=; b=FagtFR01lYjFIyS+Ap2N5He/OIEJ3GaDP3gSdLg2ivJNt+FopcWsLbgO rqHF0PSxRGOw0mSUPhKe3WmDQVDSVYnrzm8Z5ChxtKBBXfh5A49VkSWls D3L9MCyETU2gXDIvo+OrUPofzFVw9KbRN4YMSwf8zkxKNSgIxVzZgywdL /QhrAJuM8iS0HQQdC235q8waXTcfaJnFnIfaq+xEi4XZBYUDpO/mzIiIG xn01SzuXNzcvYI17QWlSTr8Eto9W/vF1pV1Hk6YqonU7hbIVVJoJXDmXE FDG70zAinYnXjqueo5rNIDGojB6640toRLC4vQ5/aY6wREhisNNf5oJsK Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="22229607" X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="22229607" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="15593743" From: Zhao Liu To: Thomas Huth , Markus Armbruster , Michael Roth , Michael Tokarev , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Zhao Liu , Eric Blake , Vladimir Sementsov-Ogievskiy , Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org Subject: [PATCH v2 05/29] block/nbd: Fix missing ERRP_GUARD() for error_prepend() Date: Mon, 11 Mar 2024 11:37:58 +0800 Message-Id: <20240311033822.3142585-6-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> References: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.10; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.945, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1710127565334100005 Content-Type: text/plain; charset="utf-8" From: Zhao Liu As the comment in qapi/error, passing @errp to error_prepend() requires ERRP_GUARD(): * =3D Why, when and how to use ERRP_GUARD() =3D * * Without ERRP_GUARD(), use of the @errp parameter is restricted: ... * - It should not be passed to error_prepend(), error_vprepend() or * error_append_hint(), because that doesn't work with &error_fatal. * ERRP_GUARD() lifts these restrictions. * * To use ERRP_GUARD(), add it right at the beginning of the function. * @errp can then be used without worrying about the argument being * NULL or &error_fatal. ERRP_GUARD() could avoid the case when @errp is &error_fatal, the user can't see this additional information, because exit() happens in error_setg earlier than information is added [1]. The nbd_co_do_receive_one_chunk() passes @errp to error_prepend() without ERRP_GUARD(), and though its @errp parameter points to its caller's local_err, to follow the requirement of @errp, add missing ERRP_GUARD() at the beginning of this function. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: Eric Blake Cc: Vladimir Sementsov-Ogievskiy Cc: Kevin Wolf Cc: Hanna Reitz Cc: qemu-block@nongnu.org Signed-off-by: Zhao Liu Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/nbd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/nbd.c b/block/nbd.c index b9d4f935e017..ef05f7cdfd65 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -852,6 +852,7 @@ static coroutine_fn int nbd_co_do_receive_one_chunk( BDRVNBDState *s, uint64_t cookie, bool only_structured, int *request_ret, QEMUIOVector *qiov, void **payload, Error **errp) { + ERRP_GUARD(); int ret; int i =3D COOKIE_TO_INDEX(cookie); void *local_payload =3D NULL; --=20 2.34.1 From nobody Thu May 16 06:18:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1710127704; cv=none; d=zohomail.com; s=zohoarc; b=S8HvxQNC41yDQuuwaUquLaFj1ynVhSAJdpgL+6ZIqaKRIcL9TxvFT1AQE+CHLTyalhJTYC+/fuWC57olBMI11nPm73K0GcXx6wcJFtwlAOphjrbSIYWI4MedxnGYnFGDx8bhjXZEc3GRD4b7v2tfiQGkP0hchlpDdIZmpun1psM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710127704; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1s2WBlusChiYRW5smURAwLHSXCROd36ACSoLOgxKzko=; b=W5QK60JX4cF9RCpU1uDXm8AnLyGtFL6FJ3MibUhcUEtBMUDx4axK1qTHXKfrSnbBS+zdCcd9vqa3+5klrYXFGkTURJY05S1jNeuLsSWhhuExU/V7ozDTAsHYw0A/6CSBDZDH+jnd+mle4eb3CtHiMbCOK/2KMddpIdB2k9v5aGo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710127704396333.44741018758543; Sun, 10 Mar 2024 20:28:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjWHp-0005cY-82; Sun, 10 Mar 2024 23:25:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWHh-0005bT-MA; Sun, 10 Mar 2024 23:25:05 -0400 Received: from mgamail.intel.com ([198.175.65.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWHe-0007rZ-TW; Sun, 10 Mar 2024 23:25:05 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2024 20:25:00 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa003.fm.intel.com with ESMTP; 10 Mar 2024 20:24:57 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710127503; x=1741663503; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=n7x/NGlcrymeFElMS75k5Vxzn/ea0m2ZkbkONubxDgw=; b=dyNOyScc6vDSdBb0T4JLgOycc0jWe6bXh20BSswPl05oVpk/DUGz+NY/ G79064ppSmx4if8gKEgF00TaEhnVv1p5o/Cej1LHr2urMge0K1YM6p0Om hi3fg53aRVq6t7+3dztqvJZb1SfYCd/w+aTzw61kaD9iQ1/j+JgjoajLl JVLRmCJVuqWUqNAdPrINkQRQgiAKpehM0MsxT5dSpB9g0HBD+G4Chbd1n CLwXFno1Ro/v306UyRKalp0MnoT9U3ho+EhSPxi1BvWY/atifjCWVEYUr 0XoNWCZAq8/pzk+jT5a+21tZQYTnfVd0gcZajToYJgSF0EqRgLcOeL7mN g==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="22229615" X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="22229615" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="15593759" From: Zhao Liu To: Thomas Huth , Markus Armbruster , Michael Roth , Michael Tokarev , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Zhao Liu , Stefan Hajnoczi , Fam Zheng , Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org Subject: [PATCH v2 06/29] block/nvme: Fix missing ERRP_GUARD() for error_prepend() Date: Mon, 11 Mar 2024 11:37:59 +0800 Message-Id: <20240311033822.3142585-7-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> References: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.10; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.945, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1710127705148100001 From: Zhao Liu As the comment in qapi/error, passing @errp to error_prepend() requires ERRP_GUARD(): * =3D Why, when and how to use ERRP_GUARD() =3D * * Without ERRP_GUARD(), use of the @errp parameter is restricted: ... * - It should not be passed to error_prepend(), error_vprepend() or * error_append_hint(), because that doesn't work with &error_fatal. * ERRP_GUARD() lifts these restrictions. * * To use ERRP_GUARD(), add it right at the beginning of the function. * @errp can then be used without worrying about the argument being * NULL or &error_fatal. ERRP_GUARD() could avoid the case when @errp is &error_fatal, the user can't see this additional information, because exit() happens in error_setg earlier than information is added [1]. In nvme.c, there are 3 functions passing @errp to error_prepend() without ERRP_GUARD(): - nvme_init_queue() - nvme_create_queue_pair() - nvme_identify() All these 3 functions take their @errp parameters from the nvme_file_open(), which is a BlockDriver.bdrv_nvme() method and its @errp points to its caller's local_err. Though these 3 cases haven't trigger the issue like [1] said, to follow the requirement of @errp, add missing ERRP_GUARD() at their beginning. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: Stefan Hajnoczi Cc: Fam Zheng Cc: "Philippe Mathieu-Daud=C3=A9" Cc: Kevin Wolf Cc: Hanna Reitz Cc: qemu-block@nongnu.org Signed-off-by: Zhao Liu Reviewed-by: Stefan Hajnoczi --- block/nvme.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/block/nvme.c b/block/nvme.c index 0a0a0a6b36cd..3a3c6da73d29 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -168,6 +168,7 @@ static QemuOptsList runtime_opts =3D { static bool nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q, unsigned nentries, size_t entry_bytes, Error *= *errp) { + ERRP_GUARD(); size_t bytes; int r; =20 @@ -221,6 +222,7 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeSt= ate *s, unsigned idx, size_t size, Error **errp) { + ERRP_GUARD(); int i, r; NVMeQueuePair *q; uint64_t prp_list_iova; @@ -535,6 +537,7 @@ static int nvme_admin_cmd_sync(BlockDriverState *bs, Nv= meCmd *cmd) /* Returns true on success, false on failure. */ static bool nvme_identify(BlockDriverState *bs, int namespace, Error **err= p) { + ERRP_GUARD(); BDRVNVMeState *s =3D bs->opaque; bool ret =3D false; QEMU_AUTO_VFREE union { --=20 2.34.1 From nobody Thu May 16 06:18:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1710127586; cv=none; d=zohomail.com; s=zohoarc; b=b5D3a0OIN5cF0B5RmYc7230rlbqwhpXyzIc3hZGM19XiAsDPI8n4PRuke/RG87Jfwe9QuQ9lxlf4xqJErt6jqCEuAupTPJ0lb0014GDMzOqEuUqqrR/AL9Dbse+lO9yknUVgNHlRodAra7yoU0MNjxTNy2LUzXgoEysrEBjZ3Pw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710127586; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=UNFm2BqEfoOW0H7mOhXEvrnPLoqylTA5i5wdHoN5s6Q=; b=JdVWMwk8+EFDIGWi+YnNHYfKDCmLkphiDKvrKpHj59A+4zpNKXCYCCO43go9YkKoGKINkX3wSqGzUScWkC/iYBuFA3DU5ajJf4Haim+Xg/2qLAee/Fs6+7b7k7GcLKFTuN5N4EhdIhDY8/irQZNshD6ALc0gl2Num5Ii6n0cvOE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710127586049370.36935602345807; Sun, 10 Mar 2024 20:26:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjWI3-0005hc-Mq; Sun, 10 Mar 2024 23:25:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWHr-0005dC-O6; Sun, 10 Mar 2024 23:25:15 -0400 Received: from mgamail.intel.com ([198.175.65.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWHi-0007rZ-Sc; Sun, 10 Mar 2024 23:25:14 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2024 20:25:04 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa003.fm.intel.com with ESMTP; 10 Mar 2024 20:25:00 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710127506; x=1741663506; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1emxAnpuDpfq0H+rINlWwFRw8yLAOk+zf7VvnHFfjxo=; b=ffeHGHuEynlGQtXgyl4vMEKiaXSJe896t8PRAhoAwklhFLN1ZDt/K0jU 2Z5pdWGFWdkWD45JXcoKDtv4/5Gq2SQMkj3Ill/CPQFMjdgkdLaK8kVQs 6CW7p52ZgYi5i+U1E0QADj279yjnJ5TEZEVDXcM5aNmq0AZR0kbnt6aQj YWP2YvuW7pQKiWe/FqlrR/p7Fp27BQL5RaPoPG7bD49Va0G1nlEkY8IaP saS9KKqEuOQBFWoA+StFB6nMgEwkRh8RljLY/QZuol6B/3oZRbRnbHfH9 qJ54js5TMgJDiRurSJduw4MUczRxaXkfeH0T03TjZngIkdnZtwhwJYMvr w==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="22229624" X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="22229624" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="15593770" From: Zhao Liu To: Thomas Huth , Markus Armbruster , Michael Roth , Michael Tokarev , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Zhao Liu , Kevin Wolf , Hanna Reitz , Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , qemu-block@nongnu.org Subject: [PATCH v2 07/29] block/qcow2-bitmap: Fix missing ERRP_GUARD() for error_prepend() Date: Mon, 11 Mar 2024 11:38:00 +0800 Message-Id: <20240311033822.3142585-8-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> References: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.10; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.945, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1710127586993100001 Content-Type: text/plain; charset="utf-8" From: Zhao Liu As the comment in qapi/error, passing @errp to error_prepend() requires ERRP_GUARD(): * =3D Why, when and how to use ERRP_GUARD() =3D * * Without ERRP_GUARD(), use of the @errp parameter is restricted: ... * - It should not be passed to error_prepend(), error_vprepend() or * error_append_hint(), because that doesn't work with &error_fatal. * ERRP_GUARD() lifts these restrictions. * * To use ERRP_GUARD(), add it right at the beginning of the function. * @errp can then be used without worrying about the argument being * NULL or &error_fatal. ERRP_GUARD() could avoid the case when @errp is &error_fatal, the user can't see this additional information, because exit() happens in error_setg earlier than information is added [1]. The qcow2_co_can_store_new_dirty_bitmap() passes @errp to error_prepend(). As a BlockDriver.bdrv_co_can_store_new_dirty_bitmap method, it's called by bdrv_co_can_store_new_dirty_bitmap(). Its caller is not being called anywhere, but as the API in include/block/block-io.h, we can't ensure what kind of @errp future users will pass in. To avoid potential issues as [1] said, add missing ERRP_GUARD() at the beginning of qcow2_co_can_store_new_dirty_bitmap(). [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: Kevin Wolf Cc: Hanna Reitz Cc: Eric Blake Cc: Vladimir Sementsov-Ogievskiy Cc: John Snow Cc: qemu-block@nongnu.org Signed-off-by: Zhao Liu Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/qcow2-bitmap.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c index 0e567ed588d7..874ea5694851 100644 --- a/block/qcow2-bitmap.c +++ b/block/qcow2-bitmap.c @@ -1710,6 +1710,7 @@ bool coroutine_fn qcow2_co_can_store_new_dirty_bitmap= (BlockDriverState *bs, uint32_t granularity, Error **errp) { + ERRP_GUARD(); BDRVQcow2State *s =3D bs->opaque; BdrvDirtyBitmap *bitmap; uint64_t bitmap_directory_size =3D 0; --=20 2.34.1 From nobody Thu May 16 06:18:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1710127756; cv=none; d=zohomail.com; s=zohoarc; b=LWSrThILzEyfla/F+AUGMwFatq0jBGhDQbkV4qJN4ftrCUaoexxF/04A2onlpkp7WKAh/3rhZyJA/BiyTukCqSnoWPaQMX5nWbEk2U1aExRLO6Yp3gvmtSXyNaTw44BRDr0mHFo7fefDwvbYM2N9gEUY3NALm3z32KldlnS/O6U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710127756; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Tpoi/CBgyZgOLnW1KsJBBboAt1vgfeNekbYs+Fpcn+s=; b=Y0PjXMfqrXeJ2jzGmx5DYGgX41LzcP4Mrl/6Nf4FHbr3KNsmhSbQ7oFI1Te7bmPGU1iNZbmXI82UKJbVHitsdx1WNitg8JIkVGiz1OK1IpUuTw2ZGEfGN/2DbmhK+l2LslpuxwQtp4zCXwPxrXrcOwXdgDE3ap+MVVaTuFsU9wg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710127756754695.8835903821222; Sun, 10 Mar 2024 20:29:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjWHz-0005du-FX; Sun, 10 Mar 2024 23:25:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWHr-0005dJ-Ul; Sun, 10 Mar 2024 23:25:16 -0400 Received: from mgamail.intel.com ([198.175.65.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWHq-00084P-4E; Sun, 10 Mar 2024 23:25:15 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2024 20:25:07 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa003.fm.intel.com with ESMTP; 10 Mar 2024 20:25:04 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710127514; x=1741663514; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UApyMmGs7NxGJ7nyTsQeSlDiPd1XDqLXAIr9okAi3X4=; b=CtWF06wf2siRU7dLKa9HDjeWKuZm5uxaIo/qgRS6mEzfGX4dVBggBsnw gKoC/f2BHsqis1AL5E6FKS0B+RyzNNuOq0uRmnMYzwdDLuqQL2YdTx/ux HfsDX3oh/8r9qjSpq+5yhYHPJcBTW8SKEvakyDVSgqQXssvIUfv7y3rhu L6EDglclgqG2YbURr1evb+7pY6adrSGyJggbkJ+XwnKoex5A3tMrPfnwo g4+uGwu/CpQH31RbqSJtPomvNl/oxb4qdN3uYuI4G+4gV9TCp0pK3zCO8 WvtnvzXJfBhtAWNs21+wEZeJRPVzB0J1fb0PWsJtMh5IgIiQm008RnMJ4 g==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="22229633" X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="22229633" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="15593784" From: Zhao Liu To: Thomas Huth , Markus Armbruster , Michael Roth , Michael Tokarev , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Zhao Liu , Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org, Eric Blake Subject: [PATCH v2 08/29] block/qcow2: Fix missing ERRP_GUARD() for error_prepend() Date: Mon, 11 Mar 2024 11:38:01 +0800 Message-Id: <20240311033822.3142585-9-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> References: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.10; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.945, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1710127757295100001 Content-Type: text/plain; charset="utf-8" From: Zhao Liu As the comment in qapi/error, passing @errp to error_prepend() requires ERRP_GUARD(): * =3D Why, when and how to use ERRP_GUARD() =3D * * Without ERRP_GUARD(), use of the @errp parameter is restricted: ... * - It should not be passed to error_prepend(), error_vprepend() or * error_append_hint(), because that doesn't work with &error_fatal. * ERRP_GUARD() lifts these restrictions. * * To use ERRP_GUARD(), add it right at the beginning of the function. * @errp can then be used without worrying about the argument being * NULL or &error_fatal. ERRP_GUARD() could avoid the case when @errp is &error_fatal, the user can't see this additional information, because exit() happens in error_setg earlier than information is added [1]. In block/qcow2.c, there are 2 functions passing @errp to error_prepend() without ERRP_GUARD(): - qcow2_co_create() - qcow2_co_truncate() There are too many possible callers to check the impact of the defect; it may or may not be harmless. Thus it is necessary to protect @errp with ERRP_GUARD(). Therefore, to avoid the issue like [1] said, add missing ERRP_GUARD() at their beginning. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: Kevin Wolf Cc: Hanna Reitz Cc: qemu-block@nongnu.org Signed-off-by: Zhao Liu Reviewed-by: Eric Blake --- v2: * Use Markus' sentence to polish commit message. (Markus) * Fix typo. (Eric) --- block/qcow2.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block/qcow2.c b/block/qcow2.c index 204f5854cff2..956128b40948 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3483,6 +3483,7 @@ static uint64_t qcow2_opt_get_refcount_bits_del(QemuO= pts *opts, int version, static int coroutine_fn GRAPH_UNLOCKED qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp) { + ERRP_GUARD(); BlockdevCreateOptionsQcow2 *qcow2_opts; QDict *options; =20 @@ -4283,6 +4284,7 @@ static int coroutine_fn GRAPH_RDLOCK qcow2_co_truncate(BlockDriverState *bs, int64_t offset, bool exact, PreallocMode prealloc, BdrvRequestFlags flags, Error **e= rrp) { + ERRP_GUARD(); BDRVQcow2State *s =3D bs->opaque; uint64_t old_length; int64_t new_l1_size; --=20 2.34.1 From nobody Thu May 16 06:18:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1710127752; cv=none; d=zohomail.com; s=zohoarc; b=gavtJvyYe4w4pWuZnrxMIQ8dTQCH1GN8Voe8+yt9bxKAa41fWWxpJ0LuW2w0EWaDzhyE2gk0uFbky0s0oiUuzDF8qbb80aoo+5yVFuZN9i9qX0uwSNpwqXin+h2aSiE4VFPpv3h8W7aiZCBc7wJVTFqhTQubNPUkSAZZIJIDAzk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710127752; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PAH5edEM1x8q+2IBmu59L/FR+3VEtmh/ER4C5ERSxmU=; b=lmaEYf8RWDacSYbG186mf7D+ziJhQ/q7PvxguNBBbUC0JM/gw01Numo0VWEQT2mv0earqKluqHsqVoDFEom5aAgC+VKJpj1TFVmDZcmIXVA6oSwbxZfGiepMDNfINfcjXIZ0zL25C9+R1Pv+4fMpL0LBTmRNHyVoRiaz4+Ow6MI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710127752369652.3326760171642; Sun, 10 Mar 2024 20:29:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjWI4-0005hs-B4; Sun, 10 Mar 2024 23:25:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWI0-0005fZ-9n; Sun, 10 Mar 2024 23:25:24 -0400 Received: from mgamail.intel.com ([198.175.65.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWHq-00085e-L9; Sun, 10 Mar 2024 23:25:24 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2024 20:25:10 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa003.fm.intel.com with ESMTP; 10 Mar 2024 20:25:07 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710127514; x=1741663514; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rXT52kQTMV0QpLJDW1r5yUbIXX8ae4g4UM9QXgujzJA=; b=ih4eZi2hAgF3vWPHRsXFf5zspbF0yHQh8OvF+SK+Dq3lcODT/N0WPNJ8 +UyBnfZsSxY2SEjK2fQEnyOU428rI5kprnlFX4LzMnhHqi4u7aVibGCHL wIVrI6P8NrGv7N2Fh0ppICCOnszVLRmaUzbCAmoRUT5UBA09fMWoB5jFC C19e9ZacnWs/DNcVnBOeoioAEeilmeYA+ZgUmx/+LGtdbJ5wIxo1wW32g guss+R0gfSAsIY17IuVcyPtyZwKwW7NkcG3r4kbfeyPz3Iu/pqWBQ+Dri yvCCTpTOVrDxd2H/8NxQvj1BrP4GmQbw5ZmBFrgbLZVqeYNeLzmvO0bbI Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="22229640" X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="22229640" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="15593791" From: Zhao Liu To: Thomas Huth , Markus Armbruster , Michael Roth , Michael Tokarev , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Zhao Liu , Stefan Hajnoczi , Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org Subject: [PATCH v2 09/29] block/qed: Fix missing ERRP_GUARD() for error_prepend() Date: Mon, 11 Mar 2024 11:38:02 +0800 Message-Id: <20240311033822.3142585-10-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> References: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.10; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.945, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1710127753294100001 Content-Type: text/plain; charset="utf-8" From: Zhao Liu As the comment in qapi/error, passing @errp to error_prepend() requires ERRP_GUARD(): * =3D Why, when and how to use ERRP_GUARD() =3D * * Without ERRP_GUARD(), use of the @errp parameter is restricted: ... * - It should not be passed to error_prepend(), error_vprepend() or * error_append_hint(), because that doesn't work with &error_fatal. * ERRP_GUARD() lifts these restrictions. * * To use ERRP_GUARD(), add it right at the beginning of the function. * @errp can then be used without worrying about the argument being * NULL or &error_fatal. ERRP_GUARD() could avoid the case when @errp is &error_fatal, the user can't see this additional information, because exit() happens in error_setg earlier than information is added [1]. The bdrv_qed_co_invalidate_cache() passes @errp to error_prepend() without ERRP_GUARD(). Though it is a BlockDriver.bdrv_co_invalidate_cache() method, and currently its @errp parameter only points to callers' local_err, to follow the requirement of @errp, add missing ERRP_GUARD() at the beginning of this function. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: Stefan Hajnoczi Cc: Kevin Wolf Cc: Hanna Reitz Cc: qemu-block@nongnu.org Signed-off-by: Zhao Liu Reviewed-by: Stefan Hajnoczi --- block/qed.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/qed.c b/block/qed.c index bc2f0a61c0a9..fa5bc1108552 100644 --- a/block/qed.c +++ b/block/qed.c @@ -1579,6 +1579,7 @@ bdrv_qed_co_change_backing_file(BlockDriverState *bs,= const char *backing_file, static void coroutine_fn GRAPH_RDLOCK bdrv_qed_co_invalidate_cache(BlockDriverState *bs, Error **errp) { + ERRP_GUARD(); BDRVQEDState *s =3D bs->opaque; int ret; =20 --=20 2.34.1 From nobody Thu May 16 06:18:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1710127588; cv=none; d=zohomail.com; s=zohoarc; b=YRjD30U5WY266o1BjQ7pfBCug18DK3Op9ObSa2EwKc6Bm5fegom1WSxcWwYwunS9jERCRLOCwuBX7FEBC+YlukYEQF/kYze+NZpR1g1knlkbwJrfbN1op36W/nhHEMj3F2ibHwUQ0V0ZAygVVLvhUgUABjkBaqqqns/zhnrc0Do= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710127588; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=cZGTgIecwF/RUFwmwnXcTPKsVlV3DqoEvVnHSEkM1Uk=; b=kmJEn2sQam12WJJvc0UvGT1lY36C4HQCd8UPXfYSHxE+NNSpwzpWwdDR4DwbYI8bTzf+VY5FSRH2RYYBC2rXEtB9pG8W9RCEsW8kPbZFohPdGqvquGU5Amkkau7/Z7a3yxYoMLo3l/ukTbzNxCM6ixbyBtfN4xOD078DJZ6+O2A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710127588691663.3635209465178; Sun, 10 Mar 2024 20:26:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjWI0-0005g1-Vi; Sun, 10 Mar 2024 23:25:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWHt-0005df-9g; Sun, 10 Mar 2024 23:25:17 -0400 Received: from mgamail.intel.com ([198.175.65.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWHr-0007rZ-OP; Sun, 10 Mar 2024 23:25:17 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2024 20:25:13 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa003.fm.intel.com with ESMTP; 10 Mar 2024 20:25:10 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710127515; x=1741663515; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WjnL/LJyxGY93zRzyLMMGq6wyNW54EH5AJWek80Hj5k=; b=JPmjFOXBHLCXxmqGiwdHcObN4GIO5wInWG/mtW2x5nvboPkgI8AtClDg 42uEBBQeSd4RmrryrxInx1nP5JRHzYGLZWtXRWSXvW1ViQRz8WRito9qB 3LekPGE5NX6GVebIlDdoRtUlao/68W2G2+MW86Jmq3JnFU+AY/iozvyXu Px2oiOQQCaNWQZz8Bq3PgGK6IjjooA0YuKmFazt/jBTHQHbPaNbXWvRoe +VuLYlVLivWEOyBKn3OKGu0nQyiw2HUhNJwst7YI+rZz1kqJIN6yBtE9f 93q7iP4DioBDImmfsPbFNFTAeA9/ss4m0fuzthYOHWdT3rXgRe7jM390e w==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="22229649" X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="22229649" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="15593801" From: Zhao Liu To: Thomas Huth , Markus Armbruster , Michael Roth , Michael Tokarev , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Zhao Liu , Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org Subject: [PATCH v2 10/29] block/snapshot: Fix missing ERRP_GUARD() for error_prepend() Date: Mon, 11 Mar 2024 11:38:03 +0800 Message-Id: <20240311033822.3142585-11-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> References: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.10; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.945, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1710127590686100007 Content-Type: text/plain; charset="utf-8" From: Zhao Liu As the comment in qapi/error, passing @errp to error_prepend() requires ERRP_GUARD(): * =3D Why, when and how to use ERRP_GUARD() =3D * * Without ERRP_GUARD(), use of the @errp parameter is restricted: ... * - It should not be passed to error_prepend(), error_vprepend() or * error_append_hint(), because that doesn't work with &error_fatal. * ERRP_GUARD() lifts these restrictions. * * To use ERRP_GUARD(), add it right at the beginning of the function. * @errp can then be used without worrying about the argument being * NULL or &error_fatal. ERRP_GUARD() could avoid the case when @errp is &error_fatal, the user can't see this additional information, because exit() happens in error_setg earlier than information is added [1]. In block/snapshot.c, there are 2 functions passing @errp to error_prepend() without ERRP_GUARD(): - bdrv_all_delete_snapshot() - bdrv_all_goto_snapshot() As the APIs exposed in include/block/snapshot.h, they could be called by other modules. To avoid potential issues as [1] said, add missing ERRP_GUARD() at the beginning of these 2 functions. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: Kevin Wolf Cc: Hanna Reitz Cc: qemu-block@nongnu.org Signed-off-by: Zhao Liu Reviewed-by: Thomas Huth --- block/snapshot.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block/snapshot.c b/block/snapshot.c index 8694fc0a3eba..8242b4abac41 100644 --- a/block/snapshot.c +++ b/block/snapshot.c @@ -566,6 +566,7 @@ int bdrv_all_delete_snapshot(const char *name, bool has_devices, strList *devices, Error **errp) { + ERRP_GUARD(); g_autoptr(GList) bdrvs =3D NULL; GList *iterbdrvs; =20 @@ -605,6 +606,7 @@ int bdrv_all_goto_snapshot(const char *name, bool has_devices, strList *devices, Error **errp) { + ERRP_GUARD(); g_autoptr(GList) bdrvs =3D NULL; GList *iterbdrvs; int ret; --=20 2.34.1 From nobody Thu May 16 06:18:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1710127675; cv=none; d=zohomail.com; s=zohoarc; b=EniDltBBDP9J7/2dfBPfVFFol8+7yRhFOs/izgwLLkEGuaGwtpe5rAMmxzvpbTbi0hFZukO8V3j80R86/61YQ0t50mTcNOYc7EG8pWevqKlJdtmYIQ7mg63Au2TXTQ/zZrnT6XBZwqSpECATFLm4yYkjzkaMzi8ireVpIVLqpao= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710127675; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=JIQrm6oIW4VL0L33ZbpRWTvH4B2yjaAc3DX6Droa/MA=; b=jPQxO2GuhGG4chrWjHPibMWHcWFcU/912VIsYDshtbe4Mg8dFld5ysU5CVMF5jUusY1Vo1LhguzBEe+yFw0B4FLbeYydJnSZdXbiky4hDfYSTDVCPHNURG6nON6Phh2xn9urfQ1YyTgTgBRy/m39d+PldR+vOiQtfjjTs5B7o4I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710127675563585.447703343607; Sun, 10 Mar 2024 20:27:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjWI5-0005it-GH; Sun, 10 Mar 2024 23:25:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWHz-0005ex-KW; Sun, 10 Mar 2024 23:25:23 -0400 Received: from mgamail.intel.com ([198.175.65.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWHu-00084P-GC; Sun, 10 Mar 2024 23:25:22 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2024 20:25:16 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa003.fm.intel.com with ESMTP; 10 Mar 2024 20:25:13 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710127518; x=1741663518; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Bes7rlwDGQ8CNIgLuQyKbZ+VZvPx2hyBnOndk7oQDqM=; b=KPdH9Uq2MvFKUMpvKpl6bNuGocAaeLMSJAkaM4YnQtxiL5tyZOSxIzeU Li2FdLdDnkRVieHACet2KrCMh/1kR+ZHKhN1/eE/sAfOcDxGjfnWO0NnF QR3dXt13XT0r17i7W9jzCSvwcQ5iSlcLHDc59rUbTtLTRwyG3H3sVWQMk 6GtDF1bK3JRciBb21SdOoJSiXpP5y0V/HpnIqVleaG9eXjRYkazMFJLre 2eqoZtthEyFS8YoW6s02T1gc38YunFH7L0iKABl38hoMOA8wiEpj8PYD6 IpfgEIyP8F9HmvQg64LCA/ZTKlPrGyspsod7H/TR0R2XUEULhKWUQhKKD A==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="22229656" X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="22229656" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="15593811" From: Zhao Liu To: Thomas Huth , Markus Armbruster , Michael Roth , Michael Tokarev , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Zhao Liu , Stefan Weil , Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org Subject: [PATCH v2 11/29] block/vdi: Fix missing ERRP_GUARD() for error_prepend() Date: Mon, 11 Mar 2024 11:38:04 +0800 Message-Id: <20240311033822.3142585-12-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> References: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.10; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.945, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1710127677241100009 Content-Type: text/plain; charset="utf-8" From: Zhao Liu As the comment in qapi/error, passing @errp to error_prepend() requires ERRP_GUARD(): * =3D Why, when and how to use ERRP_GUARD() =3D * * Without ERRP_GUARD(), use of the @errp parameter is restricted: ... * - It should not be passed to error_prepend(), error_vprepend() or * error_append_hint(), because that doesn't work with &error_fatal. * ERRP_GUARD() lifts these restrictions. * * To use ERRP_GUARD(), add it right at the beginning of the function. * @errp can then be used without worrying about the argument being * NULL or &error_fatal. ERRP_GUARD() could avoid the case when @errp is &error_fatal, the user can't see this additional information, because exit() happens in error_setg earlier than information is added [1]. The vdi_co_do_create() passes @errp to error_prepend() without ERRP_GUARD(), and its @errp parameter is so widely sourced that it is necessary to protect it with ERRP_GUARD(). To avoid the potential issues as [1] said, add missing ERRP_GUARD() at the beginning of this function. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: Stefan Weil Cc: Kevin Wolf Cc: Hanna Reitz Cc: qemu-block@nongnu.org Signed-off-by: Zhao Liu Reviewed-by: Thomas Huth --- block/vdi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/vdi.c b/block/vdi.c index 3b57becb9fe0..6363da08cee9 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -738,6 +738,7 @@ static int coroutine_fn GRAPH_UNLOCKED vdi_co_do_create(BlockdevCreateOptions *create_options, size_t block_size, Error **errp) { + ERRP_GUARD(); BlockdevCreateOptionsVdi *vdi_opts; int ret =3D 0; uint64_t bytes =3D 0; --=20 2.34.1 From nobody Thu May 16 06:18:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1710127752; cv=none; d=zohomail.com; s=zohoarc; b=hm4Uq0xXbjlwUmlIUMLj+Ti0XLrTZdGO37fZK2LoCxiyJB9GvzcuCLKhZSMu6uHDUslu639w2ROKzJdvR69WaGPZt9WVJlAc6dX7i8MJkM3oijBOK1o5gr+MJNDKVDEc5+WbQEFVJKEbRqo5juzDjaGXL/VxaHu1BHtDd9zcjQ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710127752; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Tuyen2D/pC7Tl/fSdw05L5hVuLaekfxHPQKyVEUVnzU=; b=NLXoatb69+9LkkW//Ll/MPwTjl5n/CrLmczu/6I6oYlx5rJD6IVX7HM5luivSapf1ikePQci3RwCIXp7hPKUPQuQ3nPc+MZ8+OWXltEUC7/NJOqnri70+P+tt/s323h2hE/Yfjta/4h/cxmpuCzz5Cpw5+6cZPAFhJEADahdcVE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17101277526651020.1045962811846; Sun, 10 Mar 2024 20:29:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjWI5-0005jR-PM; Sun, 10 Mar 2024 23:25:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWI0-0005g4-Sw; Sun, 10 Mar 2024 23:25:24 -0400 Received: from mgamail.intel.com ([198.175.65.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWHz-0007rZ-B3; Sun, 10 Mar 2024 23:25:24 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2024 20:25:19 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa003.fm.intel.com with ESMTP; 10 Mar 2024 20:25:17 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710127523; x=1741663523; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ixEs9dOFZnglqkPxeEdB/M9zEvYnvOWu4quv6IO1YXs=; b=YEyIpfvg1T1NDbRxM/IiMXoMXmyvv5LOs7hNgmBUx5ErrnmTL4EKq9PQ BXchLRmIWWtXGd3G2WxoEyncpmWwjIbuwhVxhmEiMWUvoJzHTW3+F2a+N NaMYDvhiP5WFEdXgppjeh2phxuKd7tR3OnJymKIZUHI9O+Dt5f75lY1fD vysa5zRUJL6hCgfLyujUnyLeeGwn8thp5MqwfxNeUOHE+ofRtGQ/prFZC ZZC/Sfqau5IzOuwYpzHyukrsgWb01nCxjWfYacftvxyEFe4tkTw0WtJKf M99U/h8GPvpHBW/O/xaArswcIPvLJKJuqDS7SrWNKWUCxtVuaNh1RUXjX g==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="22229667" X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="22229667" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="15593830" From: Zhao Liu To: Thomas Huth , Markus Armbruster , Michael Roth , Michael Tokarev , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Zhao Liu , Fam Zheng , Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org Subject: [PATCH v2 12/29] block/vmdk: Fix missing ERRP_GUARD() for error_prepend() Date: Mon, 11 Mar 2024 11:38:05 +0800 Message-Id: <20240311033822.3142585-13-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> References: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.10; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.945, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1710127753295100002 Content-Type: text/plain; charset="utf-8" From: Zhao Liu As the comment in qapi/error, passing @errp to error_prepend() requires ERRP_GUARD(): * =3D Why, when and how to use ERRP_GUARD() =3D * * Without ERRP_GUARD(), use of the @errp parameter is restricted: ... * - It should not be passed to error_prepend(), error_vprepend() or * error_append_hint(), because that doesn't work with &error_fatal. * ERRP_GUARD() lifts these restrictions. * * To use ERRP_GUARD(), add it right at the beginning of the function. * @errp can then be used without worrying about the argument being * NULL or &error_fatal. ERRP_GUARD() could avoid the case when @errp is &error_fatal, the user can't see this additional information, because exit() happens in error_setg earlier than information is added [1]. The vmdk_parse_extents() passes @errp to error_prepend(), and its @errp is from vmdk_open(). Though, vmdk_open(), as a BlockDriver.bdrv_open(), gets the @errp parameter which is pointer of its caller's local_err, to follow the requirement of @errp, add missing ERRP_GUARD() at the beginning of this function. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: Fam Zheng Cc: Kevin Wolf Cc: Hanna Reitz Cc: qemu-block@nongnu.org Signed-off-by: Zhao Liu Reviewed-by: Thomas Huth --- block/vmdk.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/vmdk.c b/block/vmdk.c index bf78e1238351..3b82979fdf42 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1147,6 +1147,7 @@ static int GRAPH_RDLOCK vmdk_parse_extents(const char *desc, BlockDriverState *bs, QDict *options, Error **errp) { + ERRP_GUARD(); int ret; int matches; char access[11]; --=20 2.34.1 From nobody Thu May 16 06:18:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1710127603; cv=none; d=zohomail.com; s=zohoarc; b=I+WAFGV/pxiZh7oLER45DWHJ1uxx+Kgysck4NyWZ8GdtJYeBnfARdz+yuHjWM5Ve2xdF/EV4PhbGLwVq9Ta0o2slPe7EtpMP4sWLFMCDMYfLNS88aIu7HIGb7LpRF1mSyya1yXpf4eJfKpZLSlLPvKie0MevSwsoLee948OZQ5k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710127603; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4+/u4egoleKyc7zwtPzkLW1nZHt7ajltiQTKWNmmh4Y=; b=ib0GR3g1o3/vEFw3QB8zbj+PXEy6bwtba00lg7nsLWlx9SJw3W7Y3WOKvkHHF3B4QkjD+qgQaM0tNYgxZT9mg9JApJHd1jZjQDTR8wIix6fnxJVv+mfWiHCQNmfbbKsDAOxhKDAnaPlyrKmnz9mfjIbgHJLB5MkSskTGU7gG+CE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710127603413873.288363980231; Sun, 10 Mar 2024 20:26:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjWI6-0005n6-7V; Sun, 10 Mar 2024 23:25:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWI2-0005h5-Mi; Sun, 10 Mar 2024 23:25:27 -0400 Received: from mgamail.intel.com ([198.175.65.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWI0-00084P-Om; Sun, 10 Mar 2024 23:25:26 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2024 20:25:23 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa003.fm.intel.com with ESMTP; 10 Mar 2024 20:25:20 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710127524; x=1741663524; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EXIEbq8RUu3AQ/jzQwBooQoTcHTssVhpacUjMNBJKSg=; b=nyYj3iRt1J6g9yP9JZ8NhMo4kvZmsH/WfgSw4q6G8YFPps2LD7vZuAr9 B+OeDPAubXlLvFMXxW+eHuzDfUbMgW4rWWElom0xEw/e0nJSDY1yeNk0w LFN1kNvmLftxgzWXOJ21+KIr+wHpEmqXjongJabzsbSMizCPMVgUSsAGY sDkwcMot70K+DROkND1IZvrcnQSU/1SspsTwQ5S69/PKdhuhtQVHk1/DB 6ro+3c5wjQjlDhxcjHar7ATc9ZogiwKNLCvFTsPOrF3+ARd4m+EfYwrXS 3ZAXKjR54WTZmueA2oNLTBcu0/eLJuBWC6RsD4DSBqdqKbwENththeJEP g==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="22229686" X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="22229686" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="15593863" From: Zhao Liu To: Thomas Huth , Markus Armbruster , Michael Roth , Michael Tokarev , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Zhao Liu , Stefan Hajnoczi , "Michael S. Tsirkin" , Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org Subject: [PATCH v2 13/29] block/virtio-blk: Fix missing ERRP_GUARD() for error_prepend() Date: Mon, 11 Mar 2024 11:38:06 +0800 Message-Id: <20240311033822.3142585-14-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> References: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.10; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.945, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1710127604824100001 Content-Type: text/plain; charset="utf-8" From: Zhao Liu As the comment in qapi/error, passing @errp to error_prepend() requires ERRP_GUARD(): * =3D Why, when and how to use ERRP_GUARD() =3D * * Without ERRP_GUARD(), use of the @errp parameter is restricted: ... * - It should not be passed to error_prepend(), error_vprepend() or * error_append_hint(), because that doesn't work with &error_fatal. * ERRP_GUARD() lifts these restrictions. * * To use ERRP_GUARD(), add it right at the beginning of the function. * @errp can then be used without worrying about the argument being * NULL or &error_fatal. ERRP_GUARD() could avoid the case when @errp is &error_fatal, the user can't see this additional information, because exit() happens in error_setg earlier than information is added [1]. The virtio_blk_vq_aio_context_init() passes @errp to error_prepend(). Though its @errp points its caller's local @err variable, to follow the requirement of @errp, add missing ERRP_GUARD() at the beginning of virtio_blk_vq_aio_context_init(). [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: Stefan Hajnoczi Cc: "Michael S. Tsirkin" Cc: Kevin Wolf Cc: Hanna Reitz Cc: qemu-block@nongnu.org Signed-off-by: Zhao Liu Reviewed-by: Stefan Hajnoczi Acked-by: Michael S. Tsirkin --- hw/block/virtio-blk.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 738cb2ac367d..92de315f17f7 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -1682,6 +1682,7 @@ static bool apply_iothread_vq_mapping( /* Context: BQL held */ static bool virtio_blk_vq_aio_context_init(VirtIOBlock *s, Error **errp) { + ERRP_GUARD(); VirtIODevice *vdev =3D VIRTIO_DEVICE(s); VirtIOBlkConf *conf =3D &s->conf; BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(vdev))); --=20 2.34.1 From nobody Thu May 16 06:18:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1710127566; cv=none; d=zohomail.com; s=zohoarc; b=IHnxxzzELaN+YJcJdSJUiSYECWtVyOKEeSI35VrzTvdxa3IBHHCR4HjhPC9XHqe8Pik1yz4csu6DHaZ+jblZSZows5cx2MGs28LR9dSeTBU8Hh1JVBciklhH0bNbjSPlLFUves8bzbFlVJY968tsi1BauW61BaU3+GdGH+GZ05I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710127566; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Fkvs5l3QcMG2mgIPzZcICHA1uOtTAn5wbWT2spft1sQ=; b=POIeCPYDrKtKYKp5xEe7wXh5LmeORrCpgbM6GkCm4DsX43J+3XX8jmHXTMGVi/igqmYWLcIVSKSAMzGNBDL5e8RodFYo/rXkp7qdoi6efwrzgqT01TeiF9m5w/GaO1Av98Wn7aN/J/Y3KsMm+tEc4HQGdGCVfRGyOsfeXR5flVk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710127566057265.3755922977641; Sun, 10 Mar 2024 20:26:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjWIY-0006VS-SH; Sun, 10 Mar 2024 23:25:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWIP-00066h-9I; Sun, 10 Mar 2024 23:25:50 -0400 Received: from mgamail.intel.com ([198.175.65.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWIN-00084P-ET; Sun, 10 Mar 2024 23:25:48 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2024 20:25:25 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa003.fm.intel.com with ESMTP; 10 Mar 2024 20:25:23 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710127547; x=1741663547; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dhYFu9CpNh5doFmSCgCFqfnCRHrzDYVeD6p8TJhW+Hc=; b=lA7i23TDW3Pgw2mpmtmDQr6hlLthdoofXSBGTtzN70o6iet6agJF8ar7 9xR+bbf90/NajZnhfr2bj9VIs4RL14l4QeJD0M7qKsnqlu2lk4r/g0bx7 3C78E0j4zuE0XZXd0arfDG6oGHBFPdS2u15fYK0UUBhdTnCeIqfJC8M5r x/aELWdQKhfMt3CiIGK/pju0ajycvGptJOa4YXds0CUUZKwqImoGBRRtN Qbes+x8IoEPjIVhhIXE0KPwgZpwKr/hytni8Sd1NjCN/MJnuUeFuKCJPJ t0e7Vs4Aj2/osMIK70dCekw7lyRwigbawn6UOMlcM5sFeZZuyHCwraIVT A==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="22229698" X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="22229698" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="15593888" From: Zhao Liu To: Thomas Huth , Markus Armbruster , Michael Roth , Michael Tokarev , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Zhao Liu , Paul Burton , Aleksandar Rikalo Subject: [PATCH v2 14/29] hw/core/loader-fit: Fix missing ERRP_GUARD() for error_prepend() Date: Mon, 11 Mar 2024 11:38:07 +0800 Message-Id: <20240311033822.3142585-15-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> References: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.10; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.945, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1710127566643100009 Content-Type: text/plain; charset="utf-8" From: Zhao Liu As the comment in qapi/error, passing @errp to error_prepend() requires ERRP_GUARD(): * =3D Why, when and how to use ERRP_GUARD() =3D * * Without ERRP_GUARD(), use of the @errp parameter is restricted: ... * - It should not be passed to error_prepend(), error_vprepend() or * error_append_hint(), because that doesn't work with &error_fatal. * ERRP_GUARD() lifts these restrictions. * * To use ERRP_GUARD(), add it right at the beginning of the function. * @errp can then be used without worrying about the argument being * NULL or &error_fatal. ERRP_GUARD() could avoid the case when @errp is &error_fatal, the user can't see this additional information, because exit() happens in error_setg earlier than information is added [1]. In hw/core/loader-fit.c, there are 2 functions passing @errp to error_prepend() without ERRP_GUARD(): - fit_load_kernel() - fit_load_fdt() Their @errp parameters are both the pointers of the local @err virable in load_fit(). Though they don't cause the issue like [1] said, to follow the requirement of @errp, add missing ERRP_GUARD() at their beginning. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: Paul Burton Cc: Aleksandar Rikalo Signed-off-by: Zhao Liu --- hw/core/loader-fit.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/core/loader-fit.c b/hw/core/loader-fit.c index b7c7b3ba94d4..9f20007dbb51 100644 --- a/hw/core/loader-fit.c +++ b/hw/core/loader-fit.c @@ -120,6 +120,7 @@ static int fit_load_kernel(const struct fit_loader *ldr= , const void *itb, int cfg, void *opaque, hwaddr *pend, Error **errp) { + ERRP_GUARD(); const char *name; const void *data; const void *load_data; @@ -178,6 +179,7 @@ static int fit_load_fdt(const struct fit_loader *ldr, c= onst void *itb, int cfg, void *opaque, const void *match_data, hwaddr kernel_end, Error **errp) { + ERRP_GUARD(); Error *err =3D NULL; const char *name; const void *data; --=20 2.34.1 From nobody Thu May 16 06:18:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1710127629; cv=none; d=zohomail.com; s=zohoarc; b=blKg2rgLK7oAJQpUdGz2lc8t8i9U99Tdsw9+WdmcdVXka6JDxTQywHBRirodtEKnUNsTBdf/QEvc5T5Ht36BtVXX3VHhUhP7b4tdaGZwJ4aAKTJ7Cflh0TT9rareetLwB7r8oKOWnHZyRpd0GeK9K/wacJQRgSz44a/qfUDOHuM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710127629; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=M6AF1QPtdX9rBVaOSWrvwtucR8wL505HO7DZPPy5MAU=; b=W+91uI6/p1Yt0uPsFkUiEfvpDnLOm+QLorJNXZEH94WKI/riDbdND0D2H/iU8k6lXi7amZ8zRfbTqrUAFJ9o4zR/DWi+Ry0VoSbIHMw+Lw4AwPY1rtY8aKmqcyO4Zp/UrolvNMz753OkkMPYb50XIs/2sOUZSUe8CvNyms58NvU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710127629453568.2217808762913; Sun, 10 Mar 2024 20:27:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjWIe-0006yd-Eg; Sun, 10 Mar 2024 23:26:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWIT-00069u-7a; Sun, 10 Mar 2024 23:25:53 -0400 Received: from mgamail.intel.com ([198.175.65.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWIP-0008BV-Sg; Sun, 10 Mar 2024 23:25:51 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2024 20:25:28 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa003.fm.intel.com with ESMTP; 10 Mar 2024 20:25:26 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710127549; x=1741663549; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+pGEfYcYehQQMgpVVFM6aL50Te9K+jPhcZ13DzXq8Lg=; b=G48RjoMLMIto6RLg7MdH8Ssz3zVcT0Fg5wf6p4RT/N8ZZM5GFiNtUZRB VNuz5hQMNnDXd4JpRJ8GXh60oV1kCsRItTYBJUCpNrjkk7ZEH1QbGBjvE NMt25tTEaV+Cwuj8penvC6csqhIuSenAI8MYwzU2qDALdmoJTLWqz+BhD NEDGQ8p0JFS83FwH1JTwvBHnyNvIzOi1sHdUaHZXH5sSBtAq9/13c7+22 UhWWiIsgRQ8+y5+zfArQGQPityDqQh4zV3f7nKJaMLtPwesfYrHXGj8GE 3DnGu84LJY9T8todTtYmxIdcf+05SDrLSQWMWSMW4B/cqHGhOw2J0ubLm w==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="22229715" X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="22229715" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="15593910" From: Zhao Liu To: Thomas Huth , Markus Armbruster , Michael Roth , Michael Tokarev , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Zhao Liu , Paolo Bonzini , Eduardo Habkost Subject: [PATCH v2 15/29] hw/core/qdev-properties-system: Fix missing ERRP_GUARD() for error_prepend() Date: Mon, 11 Mar 2024 11:38:08 +0800 Message-Id: <20240311033822.3142585-16-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> References: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.10; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.945, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1710127630881100001 From: Zhao Liu As the comment in qapi/error, passing @errp to error_prepend() requires ERRP_GUARD(): * =3D Why, when and how to use ERRP_GUARD() =3D * * Without ERRP_GUARD(), use of the @errp parameter is restricted: ... * - It should not be passed to error_prepend(), error_vprepend() or * error_append_hint(), because that doesn't work with &error_fatal. * ERRP_GUARD() lifts these restrictions. * * To use ERRP_GUARD(), add it right at the beginning of the function. * @errp can then be used without worrying about the argument being * NULL or &error_fatal. ERRP_GUARD() could avoid the case when @errp is &error_fatal, the user can't see this additional information, because exit() happens in error_setg earlier than information is added [1]. The set_chr() passes @errp to error_prepend() without ERRP_GUARD(). As a PropertyInfo.set method, there are too many possible callers to check the impact of this defect; it may or may not be harmless. Thus it is necessary to protect @errp with ERRP_GUARD(). To avoid the issue like [1] said, add missing ERRP_GUARD() at the beginning of this function. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: Paolo Bonzini Cc: "Daniel P. Berrang=C3=A9" Signed-off-by: Zhao Liu Reviewed-by: Markus Armbruster --- v2: Use Markus' sentence to polish commit message. (Markus) --- hw/core/qdev-properties-system.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-sys= tem.c index b45e90edb2a2..00c968f4f52b 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -242,6 +242,7 @@ static void get_chr(Object *obj, Visitor *v, const char= *name, void *opaque, static void set_chr(Object *obj, Visitor *v, const char *name, void *opaqu= e, Error **errp) { + ERRP_GUARD(); Property *prop =3D opaque; CharBackend *be =3D object_field_prop_ptr(obj, prop); Chardev *s; --=20 2.34.1 From nobody Thu May 16 06:18:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1710127620; cv=none; d=zohomail.com; s=zohoarc; b=U/b0KpS/BrnCA0WiJJGcQJCRg1WfC4n2jA32o8G9pgslhEerLZLy7OMZO0m+emmLmIy7ULlAtxzgwdl70pIC5uLSie/b0zEXTwypJJ4vCFtwPJS0sQPQqXoQdJ0quTHYwQtp8PQoQ6/dxHRoUYnRk2weJ1DcAfigq1ii+fwDJYM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710127620; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=8t81PFA62i6w5oLgJkrhNFHlftuPk/1sQ8z1Z/94dYg=; b=CdoEniRjLgSW6DLjfxwuFtPK6i9k38Zi/V68HsLztsJuCMlZFfY4ujg07/lJSqDYQecggcFNpslB91gttHRmaADOK0JPPZ0ED8Pip2BzMiz5eeU1Cf9I5WYV0s/CLKG2nyHLz7MPBKM4P6OvqytTE72qj1WmI0o7+MAsK2KR2mM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710127620463840.6130225901546; Sun, 10 Mar 2024 20:27:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjWIc-0006qI-Om; Sun, 10 Mar 2024 23:26:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWIV-0006Nk-Q9; Sun, 10 Mar 2024 23:25:56 -0400 Received: from mgamail.intel.com ([198.175.65.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWIU-0008EJ-18; Sun, 10 Mar 2024 23:25:55 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2024 20:25:31 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa003.fm.intel.com with ESMTP; 10 Mar 2024 20:25:29 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710127554; x=1741663554; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Vhjy1DpbGaIvfiMMR/WA6udExEgCFb+nLNgH2lQLdrI=; b=dtZYsyCvDkt/CYvo7HWzYUkngUEh3Ia/SND6eu66Fw0Xe08XNAeMPrdV YhRn/eFoULpYhwWSh/aFbqv+xMSHTsTl1qmj00rPUjb2RDSM05fr92EwI z9Jd7lA+hinGGcp+ifX2kZiCZv9KOkgoQgg47udZbn3Abkn84yBjXER6O Qu4nQUycRgskoHmZTPZ2MEUaaUw0WKSOrx+zrnqrLanhZ4nuPWfka911c RCc1+XlYL5BujwQcT2S/pvbEM4iss+kZkrN03t/QnXdFzPsB9yIput7rX rMqh6MyMbVbyShfitqh0QiSzlKynGF/DcvvLK90moTY6/oWhKWpnMvo4D Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="22229726" X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="22229726" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="15593950" From: Zhao Liu To: Thomas Huth , Markus Armbruster , Michael Roth , Michael Tokarev , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Zhao Liu , Juan Quintela , Manos Pitsidianakis , Michael Galaxy , Steve Sistare Subject: [PATCH v2 16/29] hw/misc/ivshmem: Fix missing ERRP_GUARD() for error_prepend() Date: Mon, 11 Mar 2024 11:38:09 +0800 Message-Id: <20240311033822.3142585-17-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> References: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.10; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.945, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1710127620894100001 Content-Type: text/plain; charset="utf-8" From: Zhao Liu As the comment in qapi/error, passing @errp to error_prepend() requires ERRP_GUARD(): * =3D Why, when and how to use ERRP_GUARD() =3D * * Without ERRP_GUARD(), use of the @errp parameter is restricted: ... * - It should not be passed to error_prepend(), error_vprepend() or * error_append_hint(), because that doesn't work with &error_fatal. * ERRP_GUARD() lifts these restrictions. * * To use ERRP_GUARD(), add it right at the beginning of the function. * @errp can then be used without worrying about the argument being * NULL or &error_fatal. ERRP_GUARD() could avoid the case when @errp is &error_fatal, the user can't see this additional information, because exit() happens in error_setg earlier than information is added [1]. The ivshmem_common_realize() passes @errp to error_prepend(), and as a DeviceClass.realize method, there are too many possible callers to check the impact of this defect; it may or may not be harmless. Thus it is necessary to protect @errp with ERRP_GUARD(). To avoid the issue like [1] said, add missing ERRP_GUARD() at the beginning of this function. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: Juan Quintela Cc: Manos Pitsidianakis Cc: Michael Galaxy Cc: Steve Sistare Signed-off-by: Zhao Liu --- v2: Use Markus' sentence to polish commit message. (Markus) --- hw/misc/ivshmem.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index a2fd0bc36544..de49d1b8a826 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -832,6 +832,7 @@ static void ivshmem_write_config(PCIDevice *pdev, uint3= 2_t address, =20 static void ivshmem_common_realize(PCIDevice *dev, Error **errp) { + ERRP_GUARD(); IVShmemState *s =3D IVSHMEM_COMMON(dev); Error *err =3D NULL; uint8_t *pci_conf; --=20 2.34.1 From nobody Thu May 16 06:18:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1710127604; cv=none; d=zohomail.com; s=zohoarc; b=EXd/tuH2M9V7eVHSmamqe0BCf7PNW9aVp7vDOOkDiPaHPMZdodOY7LyjfeiQPkefkr2Duj1YwYlbcBlHPrVZQAduPEaRpWZmnHmbbuWBDnh8hM2AnyktzO3bfv+7b09hSFPVXUuh6obX1pOwZpovVvQOWUAHh8STjownx3urcSM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710127604; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=jW/EyxZfAv6N9aajKMfRQWBLUBNPUmO81BNbcn7nmfM=; b=dnRLQxje7cRX0UwNPkWHum04KKIgAR/baNxIb8sXC2BcekARJBP33PvDG+JyMC13aXnbCX1Vr+s5NB8Jdk5nCAKDOaUd5K+68PWCXVqZX9XPMhFuweJ/zbsmrh9M8+KltFk4cVXJN6O3TqOiG+FK7x5GveiqKQ0+IPtoMn/WlUo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710127604067513.7944264976273; Sun, 10 Mar 2024 20:26:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjWIc-0006mo-8x; Sun, 10 Mar 2024 23:26:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWIU-0006M5-RL; Sun, 10 Mar 2024 23:25:55 -0400 Received: from mgamail.intel.com ([198.175.65.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWIS-00084P-1V; Sun, 10 Mar 2024 23:25:54 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2024 20:25:34 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa003.fm.intel.com with ESMTP; 10 Mar 2024 20:25:32 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710127552; x=1741663552; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+OGEjCDgDWgrBkE40f0La/lOl+AzgU5g8D4hjhE/uhg=; b=anylCoxq+7KSOofTGG8ZbvhE7yosnErIHidsxF72bmWZBIMAnkI83doL Ww46AD3cNV6Am1DJ6UxBIsPrtwmWjJDkJLQAUgo+4KXQ4DScF9m35ZpZU xlpOuip/UwlNZ1GCjA5ShW5KZthUZeP/tuqyqgEWnWiZ4sYrABd1176nl Nwrdq6pqEefvgxLEFFIusgCIOIyVYe87Mrwep2MU7W9Jw26xgYwpvX/qq i79B6Yl4MTMqLf2ckRvMU8/Vi0OGn0X/lS45ZpKN35jaa7vPV3hV62Nmy Cuq2GnfNiczgNUAEos5BCL9/AmZ0CkSDTEAGXANVWzX7W+mQld3KxaIDV w==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="22229737" X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="22229737" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="15593972" From: Zhao Liu To: Thomas Huth , Markus Armbruster , Michael Roth , Michael Tokarev , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Zhao Liu , Paolo Bonzini , Fam Zheng , "Michael S. Tsirkin" Subject: [PATCH v2 17/29] hw/scsi/vhost-scsi: Fix missing ERRP_GUARD() for error_prepend() Date: Mon, 11 Mar 2024 11:38:10 +0800 Message-Id: <20240311033822.3142585-18-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> References: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.10; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.945, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1710127604859100002 Content-Type: text/plain; charset="utf-8" From: Zhao Liu As the comment in qapi/error, passing @errp to error_prepend() requires ERRP_GUARD(): * =3D Why, when and how to use ERRP_GUARD() =3D * * Without ERRP_GUARD(), use of the @errp parameter is restricted: ... * - It should not be passed to error_prepend(), error_vprepend() or * error_append_hint(), because that doesn't work with &error_fatal. * ERRP_GUARD() lifts these restrictions. * * To use ERRP_GUARD(), add it right at the beginning of the function. * @errp can then be used without worrying about the argument being * NULL or &error_fatal. ERRP_GUARD() could avoid the case when @errp is &error_fatal, the user can't see this additional information, because exit() happens in error_setg earlier than information is added [1]. The vhost_scsi_realize() passes @errp to error_prepend(), and as a VirtioDeviceClass.realize method, its @errp is from DeviceClass.realize so that there is no guarantee that the @errp won't point to @error_fatal. To avoid the issue like [1] said, add missing ERRP_GUARD() at the beginning of this function. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: Paolo Bonzini Cc: Fam Zheng Cc: "Michael S. Tsirkin" Signed-off-by: Zhao Liu Reviewed-by: Thomas Huth --- hw/scsi/vhost-scsi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index 58a00336c2db..ae26bc19a457 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -220,6 +220,7 @@ static int vhost_scsi_set_workers(VHostSCSICommon *vsc,= bool per_virtqueue) =20 static void vhost_scsi_realize(DeviceState *dev, Error **errp) { + ERRP_GUARD(); VirtIOSCSICommon *vs =3D VIRTIO_SCSI_COMMON(dev); VHostSCSICommon *vsc =3D VHOST_SCSI_COMMON(dev); Error *err =3D NULL; --=20 2.34.1 From nobody Thu May 16 06:18:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1710127731; cv=none; d=zohomail.com; s=zohoarc; b=CE2ZHjdT3Kv6FLkl4mcJqxc5JHohQO+ySpO8KEfqrZVas4oxPLNI/vvq6K35ugmURk661oIU3DlxulLYx0g3WCiaO5A4SQ5raJe21E3dSCUdhbjDoRwt70s/z9wPuwqUvnxu1O/Uw9f4mwKTrgOaVJnIhkUBjE8BiPlSgxIkpL8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710127731; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=v+oXnYlJqYDv+Uh5Xisa1idTO2WGp9kAkgZcqkRBchc=; b=hhqw9JNi1+J3zkFa20mVB1X5zIpltPBIXJ8HsdrDZXjtMwCskUtYGQMCceIRr9dtjiNnXwrh7lV0jXw8+dvdSY2Z+LBEq1vz1obP9c6r+RzB29ZZC+Z4d57oZfbF9VVRvYpp5uvqrq563kgMr/o5obRMMXPG1j1k9RXfdo4rbqg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710127731408438.3728144016102; Sun, 10 Mar 2024 20:28:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjWIe-0006yU-FC; Sun, 10 Mar 2024 23:26:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWIW-0006Qy-Ll; Sun, 10 Mar 2024 23:25:57 -0400 Received: from mgamail.intel.com ([198.175.65.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWIU-0008BV-Ec; Sun, 10 Mar 2024 23:25:55 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2024 20:25:38 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa003.fm.intel.com with ESMTP; 10 Mar 2024 20:25:35 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710127554; x=1741663554; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vZshy9OBrsUTeZ3ltvu9CPOrZHXEn+0ngl/QLE5aqVA=; b=MsqFjWKYa7qlZNYRnlveVAgH+qHNz40U3OhLFkxg+iYGh1vbUPjyd/TE J3lfyfDnxBJ5Xvlrgue9S5BoJc5o759aDP6B+cV+XRfrpZ7JqCAgfEmT5 H3xY3h8sEkhwdjtJLKFitu4HItcXfca4s5p4O9R23UxVWbHfFW6/dZNOp HI+bEyiGBdsA56qCU01Z80KOKkU4oKBDcAAmHUMwlseNCQL00NkR1F2H6 oASXzxNV3NBhsu5CGco8OoM/6cyW7lZip7BwjrrFrAoocT8r+fi/J0Qws ivex6PK1kvt14uebQBsEEaMjiqd3Vu8MXyrFZQSg5L4GehxrebRELWYyi w==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="22229745" X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="22229745" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="15593992" From: Zhao Liu To: Thomas Huth , Markus Armbruster , Michael Roth , Michael Tokarev , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Zhao Liu , Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Tony Krowiak , Halil Pasic , Jason Herne , qemu-s390x@nongnu.org Subject: [PATCH v2 18/29] hw/vfio/ap: Fix missing ERRP_GUARD() for error_prepend() Date: Mon, 11 Mar 2024 11:38:11 +0800 Message-Id: <20240311033822.3142585-19-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> References: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.10; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.945, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1710127733248100003 From: Zhao Liu As the comment in qapi/error, passing @errp to error_prepend() requires ERRP_GUARD(): * =3D Why, when and how to use ERRP_GUARD() =3D * * Without ERRP_GUARD(), use of the @errp parameter is restricted: ... * - It should not be passed to error_prepend(), error_vprepend() or * error_append_hint(), because that doesn't work with &error_fatal. * ERRP_GUARD() lifts these restrictions. * * To use ERRP_GUARD(), add it right at the beginning of the function. * @errp can then be used without worrying about the argument being * NULL or &error_fatal. ERRP_GUARD() could avoid the case when @errp is &error_fatal, the user can't see this additional information, because exit() happens in error_setg earlier than information is added [1]. The vfio_ap_realize() passes @errp to error_prepend(), and as a DeviceClass.realize method, there are too many possible callers to check the impact of this defect; it may or may not be harmless. Thus it is necessary to protect @errp with ERRP_GUARD(). To avoid the issue like [1] said, add missing ERRP_GUARD() at the beginning of this function. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: Alex Williamson Cc: "C=C3=A9dric Le Goater" Cc: Tony Krowiak Cc: Halil Pasic Cc: Jason Herne Cc: Thomas Huth Cc: qemu-s390x@nongnu.org Signed-off-by: Zhao Liu Reviewed-by: C=C3=A9dric Le Goater --- v2: Use Markus' sentence to polish commit message. (Markus) --- hw/vfio/ap.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c index e157aa1ff79c..7c4caa593863 100644 --- a/hw/vfio/ap.c +++ b/hw/vfio/ap.c @@ -155,6 +155,7 @@ static void vfio_ap_unregister_irq_notifier(VFIOAPDevic= e *vapdev, =20 static void vfio_ap_realize(DeviceState *dev, Error **errp) { + ERRP_GUARD(); int ret; Error *err =3D NULL; VFIOAPDevice *vapdev =3D VFIO_AP_DEVICE(dev); --=20 2.34.1 From nobody Thu May 16 06:18:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1710127740; cv=none; d=zohomail.com; s=zohoarc; b=Zv07Y3escJ1MXTKc6YDehLMrnTVrCtfKi3pl53zsrF32/9zVMB1NoqvnwDLJ+BCyxZ8k4e6CRMEPj5OVcL2tWcdIMm8c4Ix3Ot0ZGTDmvPrpBgNB5rE48V0xx4k6nf6VzxGg59rPV6BLfBmLmEAzG91IabTABZzpk2nHJVMlg54= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710127740; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PXrk8gHSp0guV92Ve3uGECsYFEgI4T4hiLFYpxaVZ1E=; b=eNNP7SKXCTdgtI8GIL8HbW6RBc9rNwIy5XeVcEV1pMXy8DilqfKuqLe3LUx+qJrNJKVqqBf9RMjaf6eIMM5OGz4U3yRP7rVIjej0m2R1KQJ2BJVvtIwcm1H0KCR8KQtL2RwxjCXT3yI9robMVcW/Fbo1XjECXvk8e1IBTDl1Uck= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710127740052167.65365594644766; Sun, 10 Mar 2024 20:29:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjWIw-000848-PD; Sun, 10 Mar 2024 23:26:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWIt-0007tI-Eg; Sun, 10 Mar 2024 23:26:19 -0400 Received: from mgamail.intel.com ([198.175.65.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWIr-00084P-Lh; Sun, 10 Mar 2024 23:26:19 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2024 20:25:40 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa003.fm.intel.com with ESMTP; 10 Mar 2024 20:25:38 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710127577; x=1741663577; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RzsS+Q7k5xI37YwrtN7D37ccOEKmtvC2L46segGR2TU=; b=QYc0b9blufhyfuziL175gVo+wOptCGFlmyJBskaxug44Rrj957aYR0kw eLoSn/xuRl+BNzjRfUe895l3rfQjl1D5K62VYt4or6boLG96EhyhTqFBK QVEfP049yM7OLuOgDPPFVqYPsHcFqhqvImPYLJ4WS09XtoY8QsimVTpMI GIxetdl9HMP0INk1G+eTt4w7swBZqF3UbeBwEtu7Azq/dYHg7YFfqyz6Y 8+Ngu4FFeYWDdagxvpPMdp2NGwpR5PTBcWC8FTxdw53bWc3QDsQEBUiDR a4/OKkE5Pu76M863ZhyCwSZI/N1tNjJVZX5dZsmVm2WJl1NvuSusgO8k2 g==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="22229754" X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="22229754" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="15593999" From: Zhao Liu To: Thomas Huth , Markus Armbruster , Michael Roth , Michael Tokarev , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Zhao Liu , Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v2 19/29] hw/vfio/container: Fix missing ERRP_GUARD() for error_prepend() Date: Mon, 11 Mar 2024 11:38:12 +0800 Message-Id: <20240311033822.3142585-20-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> References: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.10; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.945, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1710127741299100001 From: Zhao Liu As the comment in qapi/error, passing @errp to error_prepend() requires ERRP_GUARD(): * =3D Why, when and how to use ERRP_GUARD() =3D * * Without ERRP_GUARD(), use of the @errp parameter is restricted: ... * - It should not be passed to error_prepend(), error_vprepend() or * error_append_hint(), because that doesn't work with &error_fatal. * ERRP_GUARD() lifts these restrictions. * * To use ERRP_GUARD(), add it right at the beginning of the function. * @errp can then be used without worrying about the argument being * NULL or &error_fatal. ERRP_GUARD() could avoid the case when @errp is &error_fatal, the user can't see this additional information, because exit() happens in error_setg earlier than information is added [1]. The vfio_get_group() passes @errp to error_prepend(). Its @errp is from vfio_attach_device(), and there are too many possible callers to check the impact of this defect; it may or may not be harmless. Thus it is necessary to protect @errp with ERRP_GUARD(). To avoid the issue like [1] said, add missing ERRP_GUARD() at the beginning of this function. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: Alex Williamson Cc: "C=C3=A9dric Le Goater" Signed-off-by: Zhao Liu Reviewed-by: Thomas Huth Reviewed-by: C=C3=A9dric Le Goater --- v2: Use Markus' sentence to polish commit message. (Markus) --- hw/vfio/container.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/vfio/container.c b/hw/vfio/container.c index bd25b9fbad2e..f66bb01f5b18 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -719,6 +719,7 @@ static void vfio_disconnect_container(VFIOGroup *group) =20 static VFIOGroup *vfio_get_group(int groupid, AddressSpace *as, Error **er= rp) { + ERRP_GUARD(); VFIOGroup *group; char path[32]; struct vfio_group_status status =3D { .argsz =3D sizeof(status) }; --=20 2.34.1 From nobody Thu May 16 06:18:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1710127632; cv=none; d=zohomail.com; s=zohoarc; b=WiQHOWzh9Ea3jw1bZGIpz/1UFhGJfQ2zIqzdtZ7M3gPU0PyYri6tuHs2BntGv2pt6vn9VCbv7mmbN4+bWXvE6OiDG11hYCcujUNwM7S8mu9Gt5h2dHJFlAYCD6rkckJ/hJYkO6S3J+dPtNs8Rl0rDKOxt2f2QBNjaWOT3W6fQyo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710127632; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3HBltkUmOE9afKcbX7zbPEpInDEYGmkweLQwzkmI70I=; b=liCOmhrpe4o2B8bD0psyEOV40AXQBCWiRphkey+9kiP3XGUgF/tG1+m10Bq85kZsWT2pJ49UUW+xqMTi+/eAdumJxucmJEGBeqnAIaJrzUjhN+yQ3M1U0tCrx+GtHhrD9bAipqSM/gw56kGObmTuyH4lhNFXb2raDm9eyT8hpMs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710127632548268.3760295516206; Sun, 10 Mar 2024 20:27:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjWIv-00082B-MU; Sun, 10 Mar 2024 23:26:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWIs-0007o8-PT; Sun, 10 Mar 2024 23:26:18 -0400 Received: from mgamail.intel.com ([198.175.65.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWIr-0008EJ-08; Sun, 10 Mar 2024 23:26:18 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2024 20:25:43 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa003.fm.intel.com with ESMTP; 10 Mar 2024 20:25:41 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710127577; x=1741663577; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IFz0JY+zc2MQkBUXwbMVKVIFtiFvbhCHaahl7QCHiEg=; b=Wvohpi1IgbzQEnt43nT0Zk+AXoO/q6arM3jDYXP7WYlTZAtrPWXsDpAW BQAz5vOMelP7Ax0geOKXhVTCFs97rEX8q+coxaec0n7pF4Qk/RQiaFMId vE+iT/e9zhOD1EGy3Txk30Nj/0/bADwDvo/78pLn19jpAmV2BklmhOxBv dx0d8yU0m5iRDhbuqrF+h/ZmZ61GD9HmPvK3XohqVqaoA8lNCt5lKSKiO CGorHwhSNVFfx4mSGjzPgj7GIC7p3QJYjwan7jTJOYvZWFgY9SYFfclpc SnTExDODQx9mVZ5uKuSkHTQDyJoioupY3WH+5Vea+XPpT6vMCi9JHb4Uk A==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="22229761" X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="22229761" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="15594019" From: Zhao Liu To: Thomas Huth , Markus Armbruster , Michael Roth , Michael Tokarev , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Zhao Liu , Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v2 20/29] hw/vfio/helpers: Fix missing ERRP_GUARD() for error_prepend() Date: Mon, 11 Mar 2024 11:38:13 +0800 Message-Id: <20240311033822.3142585-21-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> References: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.10; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.945, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1710127632859100005 From: Zhao Liu As the comment in qapi/error, passing @errp to error_prepend() requires ERRP_GUARD(): * =3D Why, when and how to use ERRP_GUARD() =3D * * Without ERRP_GUARD(), use of the @errp parameter is restricted: ... * - It should not be passed to error_prepend(), error_vprepend() or * error_append_hint(), because that doesn't work with &error_fatal. * ERRP_GUARD() lifts these restrictions. * * To use ERRP_GUARD(), add it right at the beginning of the function. * @errp can then be used without worrying about the argument being * NULL or &error_fatal. ERRP_GUARD() could avoid the case when @errp is &error_fatal, the user can't see this additional information, because exit() happens in error_setg earlier than information is added [1]. In hw/vfio/helpers.c, there are 3 functions passing @errp to error_prepend() without ERRP_GUARD(): - vfio_set_irq_signaling() - vfio_device_get_name() - vfio_device_set_fd() There are too many possible callers to check the impact of this defect; it may or may not be harmless. Thus it is necessary to protect their @errp with ERRP_GUARD(). To avoid the issue like [1] said, add missing ERRP_GUARD() at their beginning. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: Alex Williamson Cc: "C=C3=A9dric Le Goater" Signed-off-by: Zhao Liu Reviewed-by: C=C3=A9dric Le Goater --- v2: Use Markus' sentence to polish commit message. (Markus) --- hw/vfio/helpers.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/vfio/helpers.c b/hw/vfio/helpers.c index 678987080228..47b4096c05ee 100644 --- a/hw/vfio/helpers.c +++ b/hw/vfio/helpers.c @@ -110,6 +110,7 @@ static const char *index_to_str(VFIODevice *vbasedev, i= nt index) int vfio_set_irq_signaling(VFIODevice *vbasedev, int index, int subindex, int action, int fd, Error **errp) { + ERRP_GUARD(); struct vfio_irq_set *irq_set; int argsz, ret =3D 0; const char *name; @@ -613,6 +614,7 @@ bool vfio_has_region_cap(VFIODevice *vbasedev, int regi= on, uint16_t cap_type) =20 int vfio_device_get_name(VFIODevice *vbasedev, Error **errp) { + ERRP_GUARD(); struct stat st; =20 if (vbasedev->fd < 0) { @@ -644,6 +646,7 @@ int vfio_device_get_name(VFIODevice *vbasedev, Error **= errp) =20 void vfio_device_set_fd(VFIODevice *vbasedev, const char *str, Error **err= p) { + ERRP_GUARD(); int fd =3D monitor_fd_param(monitor_cur(), str, errp); =20 if (fd < 0) { --=20 2.34.1 From nobody Thu May 16 06:18:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1710127658; cv=none; d=zohomail.com; s=zohoarc; b=FBolFoJonW+Jd5IckpNcELYtjgS2m3Life+WDvuiOxApK2qaeXId2IbGNVzki2sxB8v/FjJqtimNT14rn2FJynK0Rrp+ECBgWp72COxSMOX4ShQ4swnqA/bfhVZejSjnRL/sGwTeVjWYyS60CjDliFx0mBSdvr29YZaGW69eSOU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710127658; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hdAQbwkDVlIKJrmAmHwMKJSr7Ap/Wad1poE1aWv+RwQ=; b=JyskUfeNszUenH7hLzwebo89T5Ay6UlltdqjRK5xdkIHvI0cDpNnzWqjjj1zYsr2mSbPzuJP3IZw3ayF1h5j01ySB6ADr2nO5osVvQh/W6lyIkRTL9EX2ibkopBIQoYdjg0S94lJSQGTUYlFd5BziIqBcBP7UnwSuFMudRqeT6A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710127658098471.67746063382936; Sun, 10 Mar 2024 20:27:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjWIv-00082A-Ms; Sun, 10 Mar 2024 23:26:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWIu-0007vj-32; Sun, 10 Mar 2024 23:26:20 -0400 Received: from mgamail.intel.com ([198.175.65.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWIs-0008BV-0b; Sun, 10 Mar 2024 23:26:19 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2024 20:25:46 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa003.fm.intel.com with ESMTP; 10 Mar 2024 20:25:44 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710127578; x=1741663578; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TFnB2T5AZHrD3WQA9yPndxMlq2vhIpqQTeZDm9Rn2z4=; b=a7dOTpSF2TNOKADHGhu67C+tnWrf4JJ0m1ZafYkHRk/0zwynlBYa8nrF k3rE83zD13UScB5Q/HmAvYKBUlOgWXG3RQZIqvrZK816L5If5AN8J6b5q sIiQiJxPtKe2RDzifKgtyNyheF1zrEXEHzIEWUpoqMOj9KV2fY5tB2vqq m1YM7MPELFqh2Mi4/ioH+dn2ZEnJo0r7xV1kgrAuKK9K1bY39r4yjIXjC qjnXAFXrqnnQB9vMx+MoPC3MIdYsq3sKnc+8akTrJco2N4JrzLitl5YTw 9USdUE94njLOoWBhji73GLPIuiartX+2pB0MXOVJlq4SkV090zBrey0y/ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="22229772" X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="22229772" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="15594046" From: Zhao Liu To: Thomas Huth , Markus Armbruster , Michael Roth , Michael Tokarev , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Zhao Liu , Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v2 21/29] hw/vfio/iommufd: Fix missing ERRP_GUARD() for error_prepend() Date: Mon, 11 Mar 2024 11:38:14 +0800 Message-Id: <20240311033822.3142585-22-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> References: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.10; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.945, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1710127658996100001 From: Zhao Liu As the comment in qapi/error, passing @errp to error_prepend() requires ERRP_GUARD(): * =3D Why, when and how to use ERRP_GUARD() =3D * * Without ERRP_GUARD(), use of the @errp parameter is restricted: ... * - It should not be passed to error_prepend(), error_vprepend() or * error_append_hint(), because that doesn't work with &error_fatal. * ERRP_GUARD() lifts these restrictions. * * To use ERRP_GUARD(), add it right at the beginning of the function. * @errp can then be used without worrying about the argument being * NULL or &error_fatal. ERRP_GUARD() could avoid the case when @errp is &error_fatal, the user can't see this additional information, because exit() happens in error_setg earlier than information is added [1]. The iommufd_cdev_getfd() passes @errp to error_prepend(). Its @errp is from vfio_attach_device(), and there are too many possible callers to check the impact of this defect; it may or may not be harmless. Thus it is necessary to protect @errp with ERRP_GUARD(). To avoid the issue like [1] said, add missing ERRP_GUARD() at the beginning of this function. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: Alex Williamson Cc: "C=C3=A9dric Le Goater" Signed-off-by: Zhao Liu Reviewed-by: C=C3=A9dric Le Goater --- v2: Use Markus' sentence to polish commit message. (Markus) --- hw/vfio/iommufd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index 9bfddc136089..7baf49e6ee9e 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -116,6 +116,7 @@ static void iommufd_cdev_unbind_and_disconnect(VFIODevi= ce *vbasedev) =20 static int iommufd_cdev_getfd(const char *sysfs_path, Error **errp) { + ERRP_GUARD(); long int ret =3D -ENOTTY; char *path, *vfio_dev_path =3D NULL, *vfio_path =3D NULL; DIR *dir =3D NULL; --=20 2.34.1 From nobody Thu May 16 06:18:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1710127673; cv=none; d=zohomail.com; s=zohoarc; b=GScoFAYFcf1kWXurAZjWwGkjYH0Z0VTbAzU9qG8Fyt8//GZDMpgMYVncPgcunAK//1CpgNVwq7s4DhyawNCKYBR9/TkUXgQxtaqxHb1YIlhwNVx5ZlbAMoWJ/gwrjiLocUEFerazIy1iDrdt/GKs/430LXk93UKNkfWmSToVs1U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710127673; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=RWeOU8d8pRbpoYSmT3pxB8KVGoWz/A6wxV5hPBh/5Vw=; b=ltoe654+zyA4pY0BmLadUEG72EwedICoyuhZZXind01VIACDrpMzmTnPhOa4REXnEE01IDxruh8onIzkXtYg41/+n9KnB0eBOOfMhOnml37baBWdBb+zheB4zmzkDWg1W40Zc4JJoXduZAKrlsxMiGhU/xRk/lVnKiIFflUzybY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710127673195104.31501040002252; Sun, 10 Mar 2024 20:27:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjWJ1-0008QC-TP; Sun, 10 Mar 2024 23:26:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWIy-0008Ca-Ih; Sun, 10 Mar 2024 23:26:24 -0400 Received: from mgamail.intel.com ([198.175.65.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWIt-0008EJ-JH; Sun, 10 Mar 2024 23:26:24 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2024 20:25:56 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa003.fm.intel.com with ESMTP; 10 Mar 2024 20:25:47 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710127579; x=1741663579; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=afLKbE/iqvhvdNRjIYrME9QDTzP57P9JV3IjhSBD68c=; b=ZMZMosg4WIJRlRx05pQUpTumF9bB2piYbIc/QIimkGN8VIhjfIc5vBYJ 9LVOP/XdMyPnBR2fNHGsLwxN9/gyCfBO15lgkP/vqYZaseepOq4ARbVAr wuw/cWjPptmPVNk6vxcgNGRJN+ne5Y9IF0tVfq+OlgMsb9h46dgS+Npnd bi5ftKO62KF7DhZe4azhDx/oLJ9BO/BHQrUIEZRoY0cLi53zWVcqP+F9U SELrSczo+QMhw05VC7jBngXpQPxOPa669ddXi10CnFbucFaqvGpbFteN5 vOmViUNpgPrI3yR0qA1zSZD12j7ZUy9dSpEgZNQhea9fq8r5g9AQQnZ6n Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="22229819" X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="22229819" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="15594055" From: Zhao Liu To: Thomas Huth , Markus Armbruster , Michael Roth , Michael Tokarev , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Zhao Liu , Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v2 22/29] hw/vfio/pci-quirks: Fix missing ERRP_GUARD() for error_prepend() Date: Mon, 11 Mar 2024 11:38:15 +0800 Message-Id: <20240311033822.3142585-23-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> References: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.10; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.945, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1710127675028100003 From: Zhao Liu As the comment in qapi/error, passing @errp to error_prepend() requires ERRP_GUARD(): * =3D Why, when and how to use ERRP_GUARD() =3D * * Without ERRP_GUARD(), use of the @errp parameter is restricted: ... * - It should not be passed to error_prepend(), error_vprepend() or * error_append_hint(), because that doesn't work with &error_fatal. * ERRP_GUARD() lifts these restrictions. * * To use ERRP_GUARD(), add it right at the beginning of the function. * @errp can then be used without worrying about the argument being * NULL or &error_fatal. ERRP_GUARD() could avoid the case when @errp is &error_fatal, the user can't see this additional information, because exit() happens in error_setg earlier than information is added [1]. In hw/vfio/pci-quirks.c, there are 2 functions passing @errp to error_prepend() without ERRP_GUARD(): - vfio_add_nv_gpudirect_cap() - vfio_add_vmd_shadow_cap() There are too many possible callers to check the impact of this defect; it may or may not be harmless. Thus it is necessary to protect their @errp with ERRP_GUARD(). To avoid the issue like [1] said, add missing ERRP_GUARD() at the beginning of this function. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: Alex Williamson Cc: "C=C3=A9dric Le Goater" Signed-off-by: Zhao Liu Reviewed-by: C=C3=A9dric Le Goater --- v2: Use Markus' sentence to polish commit message. (Markus) --- hw/vfio/pci-quirks.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c index 84b1a7b9485c..496fd1ee86bd 100644 --- a/hw/vfio/pci-quirks.c +++ b/hw/vfio/pci-quirks.c @@ -1538,6 +1538,7 @@ static bool is_valid_std_cap_offset(uint8_t pos) =20 static int vfio_add_nv_gpudirect_cap(VFIOPCIDevice *vdev, Error **errp) { + ERRP_GUARD(); PCIDevice *pdev =3D &vdev->pdev; int ret, pos; bool c8_conflict =3D false, d4_conflict =3D false; @@ -1630,6 +1631,7 @@ static int vfio_add_nv_gpudirect_cap(VFIOPCIDevice *v= dev, Error **errp) #define VMD_SHADOW_CAP_LEN 24 static int vfio_add_vmd_shadow_cap(VFIOPCIDevice *vdev, Error **errp) { + ERRP_GUARD(); uint8_t membar_phys[16]; int ret, pos =3D 0xE8; =20 --=20 2.34.1 From nobody Thu May 16 06:18:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1710127705; cv=none; d=zohomail.com; s=zohoarc; b=K3wDpgkf2aybakD5Vw37qxZJ/V41T+X58UHpWy3ygjiGmkRtxQrFUW2V5guMQgGYbftopOx5hQSa9GgZtExgBz6uWEdHIP/koEkj4W5OjLkGvt6eWhaVHUdpCrZyvJQTtQoMPNuHlnYNKKg8vlgpvRqS/1HpIxPJbF8MNg9I6ak= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710127705; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5U231du1KFmEb0qnxTZKoWACIT4oey2Hxy4CW2f6FTU=; b=Ye2tx44vsd3hVKSSiwuPh9jtADW51VIqL4K2nxwgjZNawofeljw+KutZ6VIUhy68WbqpleYKL/O88UOIVseNLvuwfsxquPu7UB55tmlOhxhsijxeC32bJP8uKEkjXCmSvn+IbyHrQhMxsQFuqB0VzgdV3ye/DlMAOU5zU1PUK0Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710127705295553.3394192831266; Sun, 10 Mar 2024 20:28:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjWJJ-0001uj-Jj; Sun, 10 Mar 2024 23:26:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWJH-0001g5-53; Sun, 10 Mar 2024 23:26:43 -0400 Received: from mgamail.intel.com ([198.175.65.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWJE-00084P-ET; Sun, 10 Mar 2024 23:26:42 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2024 20:25:57 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa003.fm.intel.com with ESMTP; 10 Mar 2024 20:25:49 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710127600; x=1741663600; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DRmA9H8ISXlVE6l62evXpMS/+COxZZyFF9roexvNfSY=; b=E0ssjBz69Hhcx/d5ethT5xS0qiH2vSSb5d36nUkLXApFLMyKOKtWS62l bZRwV0Cojzeh8hzlmtREyqpXPGNgBR7a5zesqGsN7A6LwxhRLiQa9WlKB ekocKweJlqlmdEy1lsTLeSXqDARILagU0ja9wWGrp+ZYiBwsclPbInHW3 RP3zt2as6MDnX72bBj5kCN1wVho5I/RwxSQmIbLvOMyyBvoLryV3Qzh5P BgiNcM9vNYXHP/gORd/p363shll8pEA7WOP8gcNpEf8fGKd9bCNC2N264 1f8tqzHbR0TMU4PZK6SoP6OOt5rlCyVT+kqxzRSum5K4F/MLTuML8bTO9 w==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="22229826" X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="22229826" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="15594064" From: Zhao Liu To: Thomas Huth , Markus Armbruster , Michael Roth , Michael Tokarev , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Zhao Liu , Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v2 23/29] hw/vfio/pci: Fix missing ERRP_GUARD() for error_prepend() Date: Mon, 11 Mar 2024 11:38:16 +0800 Message-Id: <20240311033822.3142585-24-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> References: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.10; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.945, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1710127707152100007 From: Zhao Liu As the comment in qapi/error, passing @errp to error_prepend() requires ERRP_GUARD(): * =3D Why, when and how to use ERRP_GUARD() =3D * * Without ERRP_GUARD(), use of the @errp parameter is restricted: ... * - It should not be passed to error_prepend(), error_vprepend() or * error_append_hint(), because that doesn't work with &error_fatal. * ERRP_GUARD() lifts these restrictions. * * To use ERRP_GUARD(), add it right at the beginning of the function. * @errp can then be used without worrying about the argument being * NULL or &error_fatal. ERRP_GUARD() could avoid the case when @errp is &error_fatal, the user can't see this additional information, because exit() happens in error_setg earlier than information is added [1]. In hw/vfio/pci.c, there are 2 functions passing @errp to error_prepend() without ERRP_GUARD(): - vfio_add_std_cap() - vfio_realize() The @errp of vfio_add_std_cap() is also from vfio_realize(). And vfio_realize(), as a PCIDeviceClass.realize method, its @errp is from DeviceClass.realize so that there is no guarantee that the @errp won't point to @error_fatal. To avoid the issue like [1] said, add missing ERRP_GUARD() at their beginning. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: Alex Williamson Cc: "C=C3=A9dric Le Goater" Signed-off-by: Zhao Liu Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/pci.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index a1522a011aa5..64780d1b7933 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -2136,6 +2136,7 @@ static void vfio_check_af_flr(VFIOPCIDevice *vdev, ui= nt8_t pos) =20 static int vfio_add_std_cap(VFIOPCIDevice *vdev, uint8_t pos, Error **errp) { + ERRP_GUARD(); PCIDevice *pdev =3D &vdev->pdev; uint8_t cap_id, next, size; int ret; @@ -2942,6 +2943,7 @@ static void vfio_unregister_req_notifier(VFIOPCIDevic= e *vdev) =20 static void vfio_realize(PCIDevice *pdev, Error **errp) { + ERRP_GUARD(); VFIOPCIDevice *vdev =3D VFIO_PCI(pdev); VFIODevice *vbasedev =3D &vdev->vbasedev; char *tmp, *subsys; --=20 2.34.1 From nobody Thu May 16 06:18:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1710127674; cv=none; d=zohomail.com; s=zohoarc; b=fJeNFs/dY8vQCZcBs5Sdmm4YKd8WldAk2V2SO1vZrTbAj8/jAZAzp/SQzYBmQZobDG0IrUwNzzZywSUmn5XqII4mfpKMfi3wSAUjdT9sWyx0Y84DX/SmeXS150TKBJCQH56pKvvVoi1w2bSgiIbPLLzoTxtuZSwxEXoLPcr1ico= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710127674; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=el2Pnz2sKfBaR2c62MWp1re2owJzi23P/wHglIQulxc=; b=Fem/pI+KR3w/DeVLyOBy5FrT3J9OolnaXGgAygdF9zi28hJc1isIaUqY/r29aHAMmenKDxRaokxM0o0zt+7rQWHS5yrqPM/Sa2pNHChqs5qmQOlpbLmfcAIfQfEmKPc0rOSD1AFYhsrn69gjH74XYq2QsZtAIfxnvEd7pM3MEPg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710127674954794.9238555797782; Sun, 10 Mar 2024 20:27:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjWJW-00042W-MG; Sun, 10 Mar 2024 23:26:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWJU-0003i8-Cl; Sun, 10 Mar 2024 23:26:56 -0400 Received: from mgamail.intel.com ([198.175.65.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWJE-0008BV-QC; Sun, 10 Mar 2024 23:26:56 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2024 20:25:57 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa003.fm.intel.com with ESMTP; 10 Mar 2024 20:25:52 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710127600; x=1741663600; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GIq3Lmcu3fjMp0gf1ukU2dID2kj7OKhxGKif5k51WEs=; b=c2lydNVViTF4FzJyl3lFUybJF/4C6ILohmS2jgpq1/xFFN0nI2ezdORu KoV0swQonM9Ci/lU4WGuZAdzWw3HXPn+3FBDkEAKfzAUNglLp3fOz0BnM g3qfVEumdLsnB6IawKM4O2/aXDKLE1CLirlCJZPiGqtGMlLhJqF1vctVg /mAqYHVJFlY+cjSaAmx5SGa66n5ZRUDqALn757tZm9rFC9BZztiMHbGYm cQDGLeLRpaaRR7pEc3HRG2GhXFXzCMsihN34DR5CLWAh6GJwIDe1WX4Zy T8zhyCfDZxUOzuTerbD8MzJopRsX7WFyF+PUQxAM0Ek0oKqjGRu6sbvyI w==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="22229830" X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="22229830" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="15594068" From: Zhao Liu To: Thomas Huth , Markus Armbruster , Michael Roth , Michael Tokarev , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Zhao Liu , Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v2 24/29] hw/vfio/platform: Fix missing ERRP_GUARD() for error_prepend() Date: Mon, 11 Mar 2024 11:38:17 +0800 Message-Id: <20240311033822.3142585-25-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> References: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.10; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.945, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1710127677042100007 From: Zhao Liu As the comment in qapi/error, passing @errp to error_prepend() requires ERRP_GUARD(): * =3D Why, when and how to use ERRP_GUARD() =3D * * Without ERRP_GUARD(), use of the @errp parameter is restricted: ... * - It should not be passed to error_prepend(), error_vprepend() or * error_append_hint(), because that doesn't work with &error_fatal. * ERRP_GUARD() lifts these restrictions. * * To use ERRP_GUARD(), add it right at the beginning of the function. * @errp can then be used without worrying about the argument being * NULL or &error_fatal. ERRP_GUARD() could avoid the case when @errp is &error_fatal, the user can't see this additional information, because exit() happens in error_setg earlier than information is added [1]. The vfio_platform_realize() passes @errp to error_prepend(), and as a DeviceClass.realize method, there are too many possible callers to check the impact of this defect; it may or may not be harmless. Thus it is necessary to protect @errp with ERRP_GUARD(). To avoid the issue like [1] said, add missing ERRP_GUARD() at the beginning of this function. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: Alex Williamson Cc: "C=C3=A9dric Le Goater" Signed-off-by: Zhao Liu Reviewed-by: C=C3=A9dric Le Goater --- v2: Use Markus' sentence to polish commit message. (Markus) --- hw/vfio/platform.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c index a8d9b7da633e..dcd2365fb353 100644 --- a/hw/vfio/platform.c +++ b/hw/vfio/platform.c @@ -576,6 +576,7 @@ static int vfio_base_device_init(VFIODevice *vbasedev, = Error **errp) */ static void vfio_platform_realize(DeviceState *dev, Error **errp) { + ERRP_GUARD(); VFIOPlatformDevice *vdev =3D VFIO_PLATFORM_DEVICE(dev); SysBusDevice *sbdev =3D SYS_BUS_DEVICE(dev); VFIODevice *vbasedev =3D &vdev->vbasedev; --=20 2.34.1 From nobody Thu May 16 06:18:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1710127734; cv=none; d=zohomail.com; s=zohoarc; b=UXDdDyAUGryY5fh2tUgaMlLqzmu7HE1wAUhYIv8VWrlIxprgKZaBH4zvoozKBPhF0ddWEvemYIwCF0Z3PmU0YAvyzBc5rcrH5BhSiyQ5CFcL/No5aSIuy74A7PiYW0imO17V4RanT3eTcsG9UKb2olv7ieGNdCphoDL8wDBMF9U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710127734; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ejjne8sWcILww54ohVCc9FWebk4LRTQSXJBxppaD9Cg=; b=BBcrgTmSrAg51u7aueorrGWoA2wN93H/pAgc6W5U0TR4addEbHTP59RX7IA1hvNKGKZPW/+Ic6rLyP9FSIdUMRjJCZR7c29vaaqmA2DjpO0Vl7gCkK3whNq15tO/qF2nvCxrtA5KRpmmJJVUPujcbqIYBVJxss+vJLx94EKG+Sk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 171012773460981.80337502141936; Sun, 10 Mar 2024 20:28:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjWJM-0002MK-UW; Sun, 10 Mar 2024 23:26:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWJL-00028z-EH; Sun, 10 Mar 2024 23:26:47 -0400 Received: from mgamail.intel.com ([198.175.65.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWJJ-0008EJ-Bg; Sun, 10 Mar 2024 23:26:47 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2024 20:25:57 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa003.fm.intel.com with ESMTP; 10 Mar 2024 20:25:55 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710127605; x=1741663605; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9ayhOJuCQ4MJTTJHMLUMPI61IaoZ8oXaXLwtDkGmbN8=; b=PwJ4PQBXi1NFG4TskEQ3mWzSn52z9AAjMKwI0d+vybsYwr9RKuYmu4tW 1BaEuC//wlmVbh3CUm7s5JRjlPwS9kVTY65esWYtT1shJZUsZlBofUib3 biKoE8V7TDbX9gBWlE428xXPsZiN2a3iqaEiRoMfrF0YCYRmkZFX7tM+v 0UCacIsbua4KeuEUXwR9DRP6spsgI9WimiXmohxXoKvdO5zc0HvEdTZyU ekgPwXaDO3R6NEPAPMT2N3OO8tJ8FvUoPZ7s+bpRmwDmIDDAc+/T5R3q4 PcT1vnxIAjiWLVkbTfIi99UkT4Y+1yOqt+cEwm8u+NT/Cc78Na9TKbX+R Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="22229835" X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="22229835" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="15594080" From: Zhao Liu To: Thomas Huth , Markus Armbruster , Michael Roth , Michael Tokarev , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Zhao Liu , "Michael S. Tsirkin" Subject: [PATCH v2 25/29] hw/virtio/vhost-vsock: Fix missing ERRP_GUARD() for error_prepend() Date: Mon, 11 Mar 2024 11:38:18 +0800 Message-Id: <20240311033822.3142585-26-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> References: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.10; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.945, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1710127735260100010 Content-Type: text/plain; charset="utf-8" From: Zhao Liu As the comment in qapi/error, passing @errp to error_prepend() requires ERRP_GUARD(): * =3D Why, when and how to use ERRP_GUARD() =3D * * Without ERRP_GUARD(), use of the @errp parameter is restricted: ... * - It should not be passed to error_prepend(), error_vprepend() or * error_append_hint(), because that doesn't work with &error_fatal. * ERRP_GUARD() lifts these restrictions. * * To use ERRP_GUARD(), add it right at the beginning of the function. * @errp can then be used without worrying about the argument being * NULL or &error_fatal. ERRP_GUARD() could avoid the case when @errp is &error_fatal, the user can't see this additional information, because exit() happens in error_setg earlier than information is added [1]. The vhost_vsock_device_realize() passes @errp to error_prepend(), and as a VirtioDeviceClass.realize method, its @errp is from DeviceClass.realize so that there is no guarantee that the @errp won't point to @error_fatal. To avoid the issue like [1] said, add missing ERRP_GUARD() at the beginning of this function. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: "Michael S. Tsirkin" Signed-off-by: Zhao Liu Reviewed-by: Thomas Huth --- hw/virtio/vhost-vsock.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c index d5ca0b5a1055..3d4a5a97f484 100644 --- a/hw/virtio/vhost-vsock.c +++ b/hw/virtio/vhost-vsock.c @@ -121,6 +121,7 @@ static const VMStateDescription vmstate_virtio_vhost_vs= ock =3D { =20 static void vhost_vsock_device_realize(DeviceState *dev, Error **errp) { + ERRP_GUARD(); VHostVSockCommon *vvc =3D VHOST_VSOCK_COMMON(dev); VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VHostVSock *vsock =3D VHOST_VSOCK(dev); --=20 2.34.1 From nobody Thu May 16 06:18:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1710127649; cv=none; d=zohomail.com; s=zohoarc; b=MuHm66JyoEbHKUYCYFKTHpiMJ/hBV/QF+Rk60zD+UiQGBsL7YHJZyg3bZNLLhKXIqV1sxSKZUt/cp8CG0CcVkS1ku9uqmBoZmw+qeNG9FzBx3fKCl4pYST3sLZp0r6k58V4UJH/h00barUJ/Eboed3uu96uksN6dXbg0GH+M7eQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710127649; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=IKYtAAAKZfYcgAVejoWI4JtzYcF74/cEZvN0TUVQXOs=; b=JX4lhelIR+FY2+yly6dL1wwhLw4ndW7qrOPqycnUPShlTmEYq4lRlB/Pbe5CgdysDAwrmSsg7jpmvV/Goeo2GP23/g+uriKWxU6gyrcat/z+m883HP9LiVKXLbDaRS6iKv2i9RgE/ZftdbzI60N0ekJMOSH7fvcOOWv5kpYFhDA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710127649858753.9829856268569; Sun, 10 Mar 2024 20:27:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjWJL-0002BH-Nl; Sun, 10 Mar 2024 23:26:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWJK-0001zx-7k; Sun, 10 Mar 2024 23:26:46 -0400 Received: from mgamail.intel.com ([198.175.65.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWJH-00084P-W6; Sun, 10 Mar 2024 23:26:45 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2024 20:26:00 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa003.fm.intel.com with ESMTP; 10 Mar 2024 20:25:57 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710127604; x=1741663604; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EmFbIY6Qn3mloQQLOMmHVbYM6zm0hNI5fLAvwGdEegc=; b=CaovXFTrego+dUblqRoGrPSyUyeKem1k7AQHt4E9AW+wqffiOiLPVrq7 Vp24Jhj3VYjCGHNeBc9tDbkIC6HnYX8Ij3vVMEKsDYe3F/xNXGYwPrlOr j5DAdc/RcYsM7iU8WMWrRZclfHYI5KygnNUKoqa/lJXs2mYch/sFOhoGh C2TrwPXvpvOQfpbNBj4HdtqZyNgmr9EJXuP5GiLdXdRnoa4DfcQZpH2x4 4HG1uoTU9L3qH08zU3WaFEq0cg4zEuVYyiKslQyb96Pi1HdmJ8vLSoxq0 3hAWCGkxjeBBpdA5ZmxrnkV7Cy7O3hapJVaGaUSbU9uK459qXB88Z8LAH A==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="22229844" X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="22229844" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="15594086" From: Zhao Liu To: Thomas Huth , Markus Armbruster , Michael Roth , Michael Tokarev , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Zhao Liu , "Michael S. Tsirkin" Subject: [PATCH v2 26/29] hw/virtio/vhost: Fix missing ERRP_GUARD() for error_prepend() Date: Mon, 11 Mar 2024 11:38:19 +0800 Message-Id: <20240311033822.3142585-27-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> References: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.10; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.945, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1710127650971100002 Content-Type: text/plain; charset="utf-8" From: Zhao Liu As the comment in qapi/error, passing @errp to error_prepend() requires ERRP_GUARD(): * =3D Why, when and how to use ERRP_GUARD() =3D * * Without ERRP_GUARD(), use of the @errp parameter is restricted: ... * - It should not be passed to error_prepend(), error_vprepend() or * error_append_hint(), because that doesn't work with &error_fatal. * ERRP_GUARD() lifts these restrictions. * * To use ERRP_GUARD(), add it right at the beginning of the function. * @errp can then be used without worrying about the argument being * NULL or &error_fatal. ERRP_GUARD() could avoid the case when @errp is &error_fatal, the user can't see this additional information, because exit() happens in error_setg earlier than information is added [1]. In hw/virtio/vhost.c, there are 2 functions passing @errp to error_prepend() without ERRP_GUARD(): - vhost_save_backend_state() - vhost_load_backend_state() Their @errp both points to callers' @local_err. However, as the APIs defined in include/hw/virtio/vhost.h, it is necessary to protect their @errp with ERRP_GUARD(). To follow the requirement of @errp, add missing ERRP_GUARD() at their beginning. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: "Michael S. Tsirkin" Signed-off-by: Zhao Liu Reviewed-by: Thomas Huth --- hw/virtio/vhost.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 2c9ac794680e..2e4e040db87a 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -2199,6 +2199,7 @@ int vhost_check_device_state(struct vhost_dev *dev, E= rror **errp) =20 int vhost_save_backend_state(struct vhost_dev *dev, QEMUFile *f, Error **e= rrp) { + ERRP_GUARD(); /* Maximum chunk size in which to transfer the state */ const size_t chunk_size =3D 1 * 1024 * 1024; g_autofree void *transfer_buf =3D NULL; @@ -2291,6 +2292,7 @@ fail: =20 int vhost_load_backend_state(struct vhost_dev *dev, QEMUFile *f, Error **e= rrp) { + ERRP_GUARD(); size_t transfer_buf_size =3D 0; g_autofree void *transfer_buf =3D NULL; g_autoptr(GError) g_err =3D NULL; --=20 2.34.1 From nobody Thu May 16 06:18:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1710127765; cv=none; d=zohomail.com; s=zohoarc; b=Wnmelmyd/Gyw2/Y/kt/RcevltBy0xXzfiz814WF7Ue/CZBNH0cdqF8pr++h6UaAhomGrzHw+Q8C6cWUvvJHulTKf7aEfh0zDGFx16RNm6s7GBgvzv1HJpGYUgelpNJxfiAkJONmr2opZf0tyeTl04Mk4D0xh30PceyZ5/d1ARD0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710127765; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ypcGlueSvNkr2LCshu7xpT4aCxBgJIb58baLsovJQ/c=; b=Facj1zbpa+ktH9Rg1nUHEoEIMha4VGUoli8QxSfFMBv1BUIQw1e6Ypaxxprg7G5DGqYxn0mA4ISUG2jYwzPow7X89JY0rTWFNnvpesUs0EpeEqdqHlX6AgDFgYyE69RCTOtwxqZfeM9pbdDYgICFqqbxpshd1j1hq371tILPo1s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710127765808514.9075159394476; Sun, 10 Mar 2024 20:29:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjWJN-0002Vw-T3; Sun, 10 Mar 2024 23:26:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWJM-0002Kd-M9; Sun, 10 Mar 2024 23:26:48 -0400 Received: from mgamail.intel.com ([198.175.65.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWJK-00084P-Td; Sun, 10 Mar 2024 23:26:48 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2024 20:26:02 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa003.fm.intel.com with ESMTP; 10 Mar 2024 20:26:00 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710127607; x=1741663607; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ptTuy2ckiHWNEI7SVUGTBp2K5fyc5nf3WiWP/pqmio0=; b=KPQnVflc96/GzjCWQURLWNKGvP+GJQc2f2subItWCeJ2Ise0x5CEGWdr Vk3iIWlcaU9usqUXeKqRjC17nLwoaEO0Ym6HSQNpKWbQVVmcN+DacN4ed OBMcJ/m1eC0y8b2fGVPz4lUJ9MkRKLSmyvHBkyB6uT89q/d+FlqAJVxMl 1vUj3vZJMMtcerfVJHxA6o4tQYB+4UGCsORjMl8xT8PDvcvQq7VgvAQdh 5TunE73e7pVhimBgrlXPCz7fVSSvM/v1r49NziddDVePRtznKf3BDzDxV UyS/2v7vnSi85xNNcVtzJ+vDIwEfK1lRfNB9TR0QjH02hE7vehwvgUdiG g==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="22229850" X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="22229850" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="15594090" From: Zhao Liu To: Thomas Huth , Markus Armbruster , Michael Roth , Michael Tokarev , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Zhao Liu , Peter Xu , Fabiano Rosas Subject: [PATCH v2 27/29] migration/option: Fix missing ERRP_GUARD() for error_prepend() Date: Mon, 11 Mar 2024 11:38:20 +0800 Message-Id: <20240311033822.3142585-28-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> References: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.10; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.945, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1710127767337100001 Content-Type: text/plain; charset="utf-8" From: Zhao Liu As the comment in qapi/error, passing @errp to error_prepend() requires ERRP_GUARD(): * =3D Why, when and how to use ERRP_GUARD() =3D * * Without ERRP_GUARD(), use of the @errp parameter is restricted: ... * - It should not be passed to error_prepend(), error_vprepend() or * error_append_hint(), because that doesn't work with &error_fatal. * ERRP_GUARD() lifts these restrictions. * * To use ERRP_GUARD(), add it right at the beginning of the function. * @errp can then be used without worrying about the argument being * NULL or &error_fatal. ERRP_GUARD() could avoid the case when @errp is &error_fatal, the user can't see this additional information, because exit() happens in error_setg earlier than information is added [1]. The migrate_params_check() passes @errp to error_prepend() without ERRP_GUARD(), and it could be called from migration_object_init(), where the passed @errp points to @error_fatal. Therefore, the error message echoed in error_prepend() will be lost because of the above issue. To fix this, add missing ERRP_GUARD() at the beginning of this function. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: Peter Xu Cc: Fabiano Rosas Signed-off-by: Zhao Liu Reviewed-by: Fabiano Rosas Acked-by: Peter Xu --- migration/options.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/migration/options.c b/migration/options.c index 40eb9309401c..caff0a271dff 100644 --- a/migration/options.c +++ b/migration/options.c @@ -1085,6 +1085,8 @@ void migrate_params_init(MigrationParameters *params) */ bool migrate_params_check(MigrationParameters *params, Error **errp) { + ERRP_GUARD(); + if (params->has_compress_level && (params->compress_level > 9)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "compress_level", --=20 2.34.1 From nobody Thu May 16 06:18:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1710127649; cv=none; d=zohomail.com; s=zohoarc; b=n9Cx5avRV8o68MkUGgw8wzaHSAH/ySLgUdg84xIjCyb0fqdgPpY3h6SwydKB/dNSyuovSTgsviQHs4hxHywAM47OOM+CZLjYW9iEoC3szrKvBmbKQBfA+173mi/W2OD9yTKQ8m+bZckp1EK3nY7rvFjRIgFU7Ruoe0Y7ne1SOl4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710127649; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=AkrRcIXNSh9TsEQr1AaE5MQ0gfyimGhO/SVYBG3bTsI=; b=KeO/9jQDRifd51GmoHw+BH+ZulsgGg+S6rLxLFr0tzccapovJNgIq/6l8jp+y2sYYpRhlT1BDJZBRVM+4auVsXUBqrYTCWoVMvtttTHDpjDuo+LbLbOHT+hcaBqv2AV9kIwCLLnkPRKxA2UqON0DNoHyUBMSrVsJBNhLf3fEybc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710127649504224.31689161603708; Sun, 10 Mar 2024 20:27:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjWJn-00068t-Jp; Sun, 10 Mar 2024 23:27:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWJi-0005oU-8C; Sun, 10 Mar 2024 23:27:10 -0400 Received: from mgamail.intel.com ([198.175.65.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWJg-0008EJ-6M; Sun, 10 Mar 2024 23:27:09 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2024 20:26:05 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa003.fm.intel.com with ESMTP; 10 Mar 2024 20:26:03 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710127628; x=1741663628; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PuuITxi/LVf2InU1mM00W7NeqQ6+dk76QqfYGUwraxs=; b=HP0ziY8ajKZSIK6KKBMgvUgVjCkaZzPe5iH2o7pXrEPAr7TiTcLxQWEe k9MkIKbq7H/nRPXqRkfy4JpQ5gT0mfhX4bCn+n5/UoDxPYne3RVcmKdDp U7AZ2OXkgduUzZfMMEqG9iQPC64h6k8sXLvuYlJZiT3jguxXAthFNzpml E+L1e9MgJzS2WQuWdL6lu8LVPbGenAuAr/GNZxtyukCPWnuPUrrrYl9Z7 T/mbUCl2zwdklW4iOtyrRDaHn/QOmD1cuPnnWlq7+5aAJICJabG7aB1zP kwWNBVL00Xlg+ZV8eF/IRsLz4o3Cy5HvYny0Xj7+z09/UWAbosZEOM7hu A==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="22229857" X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="22229857" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="15594096" From: Zhao Liu To: Thomas Huth , Markus Armbruster , Michael Roth , Michael Tokarev , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Zhao Liu , Jason Wang Subject: [PATCH v2 28/29] net/vhost-vdpa: Fix missing ERRP_GUARD() for error_prepend() Date: Mon, 11 Mar 2024 11:38:21 +0800 Message-Id: <20240311033822.3142585-29-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> References: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.10; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.945, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1710127650968100001 Content-Type: text/plain; charset="utf-8" From: Zhao Liu As the comment in qapi/error, passing @errp to error_prepend() requires ERRP_GUARD(): * =3D Why, when and how to use ERRP_GUARD() =3D * * Without ERRP_GUARD(), use of the @errp parameter is restricted: ... * - It should not be passed to error_prepend(), error_vprepend() or * error_append_hint(), because that doesn't work with &error_fatal. * ERRP_GUARD() lifts these restrictions. * * To use ERRP_GUARD(), add it right at the beginning of the function. * @errp can then be used without worrying about the argument being * NULL or &error_fatal. ERRP_GUARD() could avoid the case when @errp is &error_fatal, the user can't see this additional information, because exit() happens in error_setg earlier than information is added [1]. The net_init_vhost_vdpa() passes @errp to error_prepend(), and as a member of net_client_init_fun[], it's called in net_client_init1() and gets @errp from this caller. But because netdev_init_modern() passes &error_fatal to net_client_init1(), then @errp parameter of net_init_vhost_vdpa() would point to @error_fatal. This causes the error message in error_prepend() to be lost because of the above issue. To fix this, add missing ERRP_GUARD() at the beginning of this function. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: Jason Wang Signed-off-by: Zhao Liu Reviewed-by: Thomas Huth --- net/vhost-vdpa.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index e6bdb4562dde..d81baecbc1a3 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -1751,6 +1751,7 @@ static int vhost_vdpa_get_max_queue_pairs(int fd, uin= t64_t features, int net_init_vhost_vdpa(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp) { + ERRP_GUARD(); const NetdevVhostVDPAOptions *opts; uint64_t features; int vdpa_device_fd; --=20 2.34.1 From nobody Thu May 16 06:18:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1710127733; cv=none; d=zohomail.com; s=zohoarc; b=PAU/jZMMF5mQt/6ba5WCccktSSMcsiHWIK6XHTVUZ92Ld5y+TIKKiOuu48nF6i7/Z/y33lKRdhJ21kD+X/3kpGLCqWPXNTUJq7wzjvf1TTbFzHMqhHgvdPvgTp9bDQETgvVT2UBY/QWgAsAW93fgZK0mmcbgC7VATaISK13kwdc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710127733; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=mAm1N/6wkGfhEu4ezZ1krUtvPXfUwNedoscuFfxOVkk=; b=d4O0FpdFR4b4tjZWN7jGnCggfkuYPxSAw2epT0rsDX1kDL6pymQymX3Q2CHISvYTmtRomENRMfUSdTo1JpNnaDAQ0XEicQPGsvT0rmVezmYEaZGnC9Vj117sAnlSrE0XGvSN1P1CXcQKwaLWIOFsX1h/GXiQlGMgDedtFhVKOTM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710127733047227.1662998420819; Sun, 10 Mar 2024 20:28:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjWK2-0007CV-4f; Sun, 10 Mar 2024 23:27:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWJy-0006gf-F7; Sun, 10 Mar 2024 23:27:26 -0400 Received: from mgamail.intel.com ([198.175.65.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjWJr-00084P-Qo; Sun, 10 Mar 2024 23:27:26 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2024 20:26:08 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa003.fm.intel.com with ESMTP; 10 Mar 2024 20:26:05 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710127639; x=1741663639; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FUBNZoVYFulMqFdKGFhCzM+sKaGWCnMsBZAUCnXGKvA=; b=Js5ntsC+jF5IUyJ3jA8/875ojawdxu6kmPnggRQboD54D+MLAO3iy/6Z pbFF3doq6H9u/xeZkQUC44GQuPle0Xx3KlsbpjGpmSzMTooWNvx7+p12r 2CEK4QaA0kD2ilJ6oJqWUeltlPiBzMEfj63K5Y7Qwivm4QglAzFCpAsg2 Up8b/r1X6tLJVxJzfGnz5+hZETjTBbZDoanw7mqfJgc5cpyxC14MGztmb KrpJiwud/yEMIfOCxogZXzXRqIHsvl+4lewX2NUwX6PP/uDsaqal0u4pC SZx1ljvh/iwMd0WzGXDe9Na/Fo/EkJDXC+VtGbXgxpVT/4ZRRLdGxEPAw g==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="22229864" X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="22229864" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,115,1708416000"; d="scan'208";a="15594103" From: Zhao Liu To: Thomas Huth , Markus Armbruster , Michael Roth , Michael Tokarev , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Zhao Liu , David Hildenbrand , Richard Henderson , Ilya Leoshkevich , qemu-s390x@nongnu.org Subject: [PATCH v2 29/29] target/s390x/cpu_models: Fix missing ERRP_GUARD() for error_prepend() Date: Mon, 11 Mar 2024 11:38:22 +0800 Message-Id: <20240311033822.3142585-30-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> References: <20240311033822.3142585-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.10; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.945, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1710127733248100004 Content-Type: text/plain; charset="utf-8" From: Zhao Liu As the comment in qapi/error, passing @errp to error_prepend() requires ERRP_GUARD(): * =3D Why, when and how to use ERRP_GUARD() =3D * * Without ERRP_GUARD(), use of the @errp parameter is restricted: ... * - It should not be passed to error_prepend(), error_vprepend() or * error_append_hint(), because that doesn't work with &error_fatal. * ERRP_GUARD() lifts these restrictions. * * To use ERRP_GUARD(), add it right at the beginning of the function. * @errp can then be used without worrying about the argument being * NULL or &error_fatal. ERRP_GUARD() could avoid the case when @errp is &error_fatal, the user can't see this additional information, because exit() happens in error_setg earlier than information is added [1]. In target/s390x/cpu_models.c, there are 2 functions passing @errp to error_prepend() without ERRP_GUARD(): - check_compatibility() - s390_realize_cpu_model() Though both their @errp parameters point to their callers' local @err virables and don't cause the issue as [1] said, to follow the requirement of @errp, also add missing ERRP_GUARD() at their beginning. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: David Hildenbrand Cc: Thomas Huth Cc: Richard Henderson Cc: Ilya Leoshkevich Cc: qemu-s390x@nongnu.org Signed-off-by: Zhao Liu Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: C=C3=A9dric Le Goater --- target/s390x/cpu_models.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index a63d990e4e8e..1a1c09612271 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -503,6 +503,7 @@ static void error_prepend_missing_feat(const char *name= , void *opaque) static void check_compatibility(const S390CPUModel *max_model, const S390CPUModel *model, Error **errp) { + ERRP_GUARD(); S390FeatBitmap missing; =20 if (model->def->gen > max_model->def->gen) { @@ -566,6 +567,7 @@ S390CPUModel *get_max_cpu_model(Error **errp) =20 void s390_realize_cpu_model(CPUState *cs, Error **errp) { + ERRP_GUARD(); Error *err =3D NULL; S390CPUClass *xcc =3D S390_CPU_GET_CLASS(cs); S390CPU *cpu =3D S390_CPU(cs); --=20 2.34.1