From nobody Tue Nov 26 07:43:07 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=1709137550; cv=none; d=zohomail.com; s=zohoarc; b=iTff1v3T+FUyyfPwrNAyHYJbOc+6VEnQefQ0mJERUUp67X8fszni/6SzL+rgItcHdhGtuCh1ACqqIHgNtB6eRy7F+JnTuIGg5ztX1BfYaGQ+NyrLIZb00IIhvKzRd3IguFdcoCr+regY0gLK7kpn01J/8VTdXUJfChLsmiy8BYU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709137550; 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=Xgok0beyL4hdB5FdYm3wOWiQGrFi98nxkl4VHVbQZYc=; b=nK21Wi1lOFArlfjulup2XG9FHWOsa6MuQBKoM7Ys8sF+aZA02SUKQwq/yuZzUIto/+ir6NdKX3D1dqF+7RsSVYK0Hl8EcaAPHXEZTXCGJmp+NvmANmMpDCPecVcyjpfG5vK6zNDQYbtf/2eVPgb2Li4JkC4CJulRdpro18oMO9Q= 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 1709137550292980.648278677008; Wed, 28 Feb 2024 08:25:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfMis-0003rU-7d; Wed, 28 Feb 2024 11:23:58 -0500 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 1rfMip-0003qZ-Ux; Wed, 28 Feb 2024 11:23:55 -0500 Received: from mgamail.intel.com ([192.198.163.7]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfMio-0000kj-2e; Wed, 28 Feb 2024 11:23:55 -0500 Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 08:23:50 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by orviesa004.jf.intel.com with ESMTP; 28 Feb 2024 08:23:48 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709137434; x=1740673434; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ph7yx45DpHdKw7PwqnWGdtJMzif59rJ5VMJHMtnScN4=; b=etBsxr4UU4Uo5lqwRzhw7r4amZ6R3zPQmRZGFqN7xYoK9f/12hpdopSE kbqRAZ/2MEEcj8B3tp3Yjq8cPop0d+Wr/61bGa+LmLzfOFPaklWbAFXKX lZwIMFYjHXq9xi67Qt7o1Zk3mDYpRfjBgLlY+1FOQqVBMHrthXzrLG0Iz WGyTlub3U0o55ow9xZ3XnA+q3A+ZyeotFieSuuwO1Ht+EEQ7N1qwVxGNL kpErF4ggkISBCWrro7b1RmviYPNNRGwvM2vQfRviyq9O8JyHvGlle9aKG gNX3HbWOBjYIdTnICZGtjV0VwBeU1oG0XgfQ2/wheL1TCGHV8NV/2GoEi Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="28982411" X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="28982411" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="12144802" From: Zhao Liu To: 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 01/16] error: Add error_vprepend() in comment of ERRP_GUARD() rules Date: Thu, 29 Feb 2024 00:37:08 +0800 Message-Id: <20240228163723.1775791-2-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240228163723.1775791-1-zhao1.liu@linux.intel.com> References: <20240228163723.1775791-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=192.198.163.7; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: 4 X-Spam_score: 0.4 X-Spam_bar: / X-Spam_report: (0.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.102, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SORTED_RECIPS=2.499, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: 1709137550559100001 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(). Signed-off-by: Zhao Liu Reviewed-by: Markus Armbruster --- 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..b1b389967f92 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 Tue Nov 26 07:43:07 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=1709137722; cv=none; d=zohomail.com; s=zohoarc; b=X6aK2Ul/AyDwzQ7rtS0PxKwwMv5YZe8GuPsG8VqmzPw49O5b30a5aevYpSGaXtGarAQCf5SnqM/ocUr/8KIjimBZqak1dmmVLTiHktcff8/sJw1kG92QRCXzKCeJrRuRqaO4YGEd/UlCgy42O9rxKogyoNfDpktJt/Bdcphe1dY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709137722; 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=MXmTa1EMEmbc8RaR6aiaYJKdBVxi63XZKtVhroWen7c=; b=KcAvudiejE+rgvWREnouPyOTwBn8D5YscyAt3wf82iZW/7ev+Zbh6prY8uh1iAiuQxZKzMYe0CEi113QBiNcsI8X4hVuua/teZ3g3jJGXZP2dvJ5G5SCc9OTW98bW22wuXzs7ylXZ0HRWM9S8dkK21BgVDlHY/aPELiHleBSWTk= 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 1709137722904703.5705878920019; Wed, 28 Feb 2024 08:28:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfMit-0003sZ-HE; Wed, 28 Feb 2024 11:23:59 -0500 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 1rfMis-0003rX-6J; Wed, 28 Feb 2024 11:23:58 -0500 Received: from mgamail.intel.com ([192.198.163.7]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfMiq-0000mI-Bz; Wed, 28 Feb 2024 11:23:57 -0500 Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 08:23:53 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by orviesa004.jf.intel.com with ESMTP; 28 Feb 2024 08:23:50 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709137436; x=1740673436; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=k9iYhMvDZgDUYC+uUV1HBSQug6hcI5PYy6xahfkmyYw=; b=TEZuipusTDaIAsRMvb8LvO5T/LULaQSI/ohB00wYt40YTlBxK7mCSTrp +YBr2wNx6WQ8IHbTXc7ds7zHTH9ABTE4uXG97g8JnlIUM7E5XnudQ1Rot 1jxZ2PZwPWaz7ZU1jnI3dRKwuuRfmVnki6Kl7cuLR03kDnmSWysmrG8q8 DZGfJQH+rOeQhEeX43rsJhtGWnomvUDiLW7DjoYFnyaNkMy5BNkCxQF5b r273mE7E8nXOPEMEoFC1gpm28yjbizYXXBflstTzk2zQ0j9UUMFB+d9VM uJNgBvNL/lrS38iJvZOKQBm68YaYkN820dqPLPdDnNNQDcKt0tnm3gDRa w==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="28982423" X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="28982423" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="12144821" From: Zhao Liu To: 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 02/16] backends/iommufd: Fix missing ERRP_GUARD() for error_prepend() Date: Thu, 29 Feb 2024 00:37:09 +0800 Message-Id: <20240228163723.1775791-3-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240228163723.1775791-1-zhao1.liu@linux.intel.com> References: <20240228163723.1775791-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=192.198.163.7; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.102, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, 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: 1709137723124100001 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 the pointer of 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 --- 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 Tue Nov 26 07:43:07 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=1709137708; cv=none; d=zohomail.com; s=zohoarc; b=HQQ0NcYzK224XBDTU6kX14wkdW/N7iAgXMYQH3f8nHPmHyORwObCSgjjdEW0/D8PNb1KSGC50yAXtIr9yekYPfLOM0A2z7Xj170EQJ/lcDNLvuCm5qcb2rhwuWDp0YtWpe0etxQuTh+Ti4Oo9ZpXk0siWTiF4Bz++UeKyRvvf5M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709137708; 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=KnhoUBhBXPGka1yuUX3prBa87FVJly4Vc6UGqnYBpjc=; b=jWpAPBfrBoVNMuuMY2JUn6MXyF4klMq0kikgiJ6LIWdtsqVksbNw7gGENI1A7cJXHy137B6s2UPUncdQnmVL4m1q64psMktexNRjBLkAJA+qeO9GHz7GFNFxr2pd25HqWKVaI+XD5LjtvQFzq0bTsOsEOpcEBuy65B3LQSn1plo= 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 1709137708723618.0724969275733; Wed, 28 Feb 2024 08:28:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfMix-0003z9-VQ; Wed, 28 Feb 2024 11:24:04 -0500 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 1rfMiw-0003vn-Bp; Wed, 28 Feb 2024 11:24:02 -0500 Received: from mgamail.intel.com ([192.198.163.7]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfMit-0000mI-Lx; Wed, 28 Feb 2024 11:24:02 -0500 Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 08:23:56 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by orviesa004.jf.intel.com with ESMTP; 28 Feb 2024 08:23:53 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709137440; x=1740673440; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ScaB6SaBv2CqP5Ws6GB8REcTl3j7b3N6RkLZjBdmWdE=; b=YHkbNc6Mv46zUPX778EhHpHS/7HUkaFTgNlMOoFyxYdcytoZV+Ft9kmq /jh8L7FqqP6iJctpSA4RGBKWpygZZP+2NGocrAmfTfjrRmS6/PTX3UYv4 GPtkgJFRGWICqJbcJ+RUHJ5x05pnp3CglVYZEOm5BhfrvxAr9O1Vz021W pUBtrh3fgA1Wn7K9z0RtYAKcXCdFyes1NbvKuOYCxfpYvlfOqW5Bs1XQx 8HBIjDXuk//cWBRWzCbjYmBZljaq6fOA54Rvlu+AC0PuhjmL6QrMHVt9u oAcTYpXgDAYpcu9QDFun1FqBVHIf9n+SUBWee3kEjDAjB8pGy6bY/zLR7 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="28982439" X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="28982439" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="12144863" From: Zhao Liu To: 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 Subject: [PATCH 03/16] block: Fix missing ERRP_GUARD() for error_prepend() Date: Thu, 29 Feb 2024 00:37:10 +0800 Message-Id: <20240228163723.1775791-4-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240228163723.1775791-1-zhao1.liu@linux.intel.com> References: <20240228163723.1775791-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=192.198.163.7; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.102, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, 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: 1709137709139100001 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 the pointer of 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're 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(), as an implementation of BolckDriver.bdrv_co_create_opts(), its @errp parameter is so widely sourced that it is necessary to protect it 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 Signed-off-by: Zhao Liu Reviewed-by: Eric Blake --- 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 Tue Nov 26 07:43:07 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=1709137695; cv=none; d=zohomail.com; s=zohoarc; b=TQ4c5AZBBk/8x4VK/MxmCtMphzvLPkObpSszxeiDbIV7QQq83F2Yb7jGIUu+5xti6NAoe1/EHMJ4/31nt20hxmc40RQiIGlz7rEy6UFdiG9E0O0kIXjR9YFPTNiGMDTi2xGc2DBCJRgZ6y6JtXHEZPP6n40yVp7h8hPYISEn0Xk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709137695; 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=sWhZZOABss47qpEfRVEwLMwmmhLB+WBCr0B2/RLoPbU=; b=YmSYRWH+ZadMcNY0f25/tKtsSt46QDYypm5Q0krGGQXJUJrWozthA7dL/NcB/4a9dntCaqfSADx2iG5T/kVkEOjZWaMlG6FioqGHNA3WBbj7Us8DaKRmf8UWcv/2HW3skjSnwVhzV6C5tw25XiylfUC4fSFbfus7oBr4ece69IM= 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 1709137695054682.9429875438251; Wed, 28 Feb 2024 08:28:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfMix-0003yn-TN; Wed, 28 Feb 2024 11:24:03 -0500 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 1rfMiw-0003vp-Ff; Wed, 28 Feb 2024 11:24:02 -0500 Received: from mgamail.intel.com ([192.198.163.7]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfMiu-0000oF-SK; Wed, 28 Feb 2024 11:24:02 -0500 Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 08:23:59 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by orviesa004.jf.intel.com with ESMTP; 28 Feb 2024 08:23:56 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709137441; x=1740673441; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QAn6+MUVu1rKDjC913XhAj1KDjxffFbQY2JrVSnn4uQ=; b=J2BXMY4zkd24SHTTypzlbokPBK/XgrcXHDW2ggDo0ymVwav/Z7J5ZARe SESpbsLDjNRQ3oHDcVQTkYKhckKFBWhkz2dAA1Sm0Hp7uvoha8VL7eQn6 hwh97oPDUhYF9WxijwIRGlnms+Whp8qOTj/iCqHpI7O25XFSnevOzO6Zd PWG0z9NT5RMCvviXW/5DJl7L/HR4lbX/OAqYdtZmgxQAG2eu6sVdmGRQ9 prDcweQtM0qPwc9LLOktI/sVwXsT0JH2bA3dvIhZ0yZ1sxljdcYb1Fp1I sjIux3d8pXB4HPSHKo6I+qmj5komN+jeSXB25n0ugUv9zyAnMhJuKn/y2 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="28982446" X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="28982446" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="12144897" From: Zhao Liu To: 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 Subject: [PATCH 04/16] block/cbw: Fix missing ERRP_GUARD() for error_prepend() Date: Thu, 29 Feb 2024 00:37:11 +0800 Message-Id: <20240228163723.1775791-5-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240228163723.1775791-1-zhao1.liu@linux.intel.com> References: <20240228163723.1775791-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=192.198.163.7; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.102, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, 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: 1709137697081100003 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 the pointer of 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 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 Tue Nov 26 07:43:07 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=1709137499; cv=none; d=zohomail.com; s=zohoarc; b=jJVNf2ZQToEhQK6ybkga7hK05FyQJiyI0GJDjiOVNSkzadlAHw/3y5WeG2kkltwGBYlxg3BtntIt5PBregT4VMNx4nx+VEeyQcbBFw4CALK+JTW/TNfY43e1XEtFL0Gf1egbO8B8WUM3GwzBhUwQv9oSTd+KfFZJAVEOCkq739Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709137499; 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=0xBxenQrfS7Aihdbn5fxS9eaAMQKcJarXa5ykwULcCQ=; b=DeIfgBT7hwyh5UsNYnAqa83pc9ao3og3eC+085cxJwH0ANGpeKBqnP4vnmXFxCVhV+CJx709C67rUqMkPefnFsJYibuv6lXOe+pXaBDhJvKmsUP/jBJdAhIxFIjtXkJ0ILSqXtO08WbqIc69IbqBCMiwKNULv+D+RHizUld4++Y= 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 1709137499692318.35717569361987; Wed, 28 Feb 2024 08:24:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfMj5-00042W-N3; Wed, 28 Feb 2024 11:24:11 -0500 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 1rfMj4-00041f-6C; Wed, 28 Feb 2024 11:24:10 -0500 Received: from mgamail.intel.com ([192.198.163.7]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfMiz-0000pW-Gk; Wed, 28 Feb 2024 11:24:09 -0500 Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 08:24:02 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by orviesa004.jf.intel.com with ESMTP; 28 Feb 2024 08:24:00 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709137445; x=1740673445; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=c8vV9pNHPUOnOnJVX+pG0YsfcZFGOOeEdh7NHsDFh5U=; b=KOz8XP6zrw+WH9WYDN71nNiRkr5yDidpCEoSd6yQCeQpg/uNNPWUajXl liyXR18meGvcXOaA4USR3kZ4jaLKE7PNYR6QPTPKlKNU49VeVhDO3UKEf OGQd/koQ62WJCo5NIMWWsJj7J+mehyzU6P9b7ucfvuSQSqIMEfOstbcP5 5BWyMzUR5cXKtnBSkEKpR0hkdRAKfzPSWAUhMaQtSgWT/9KYD8hVQxf1h xxv1jzBMNgi01fXThkib2stgyGwPzf4q9dAhjS+apZJ5UraIstpzwUN4T EBg95JVf+KQspNKICu7l8GYZUHtjKu+xc9v9BKoqYj+3EysSdLn9M1Jrj A==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="28982459" X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="28982459" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="12144914" From: Zhao Liu To: 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 Subject: [PATCH 05/16] block/nbd: Fix missing ERRP_GUARD() for error_prepend() Date: Thu, 29 Feb 2024 00:37:12 +0800 Message-Id: <20240228163723.1775791-6-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240228163723.1775791-1-zhao1.liu@linux.intel.com> References: <20240228163723.1775791-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=192.198.163.7; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.102, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_HELO_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: 1709137500690100001 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 the pointer of 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 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 Tue Nov 26 07:43:07 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=1709137676; cv=none; d=zohomail.com; s=zohoarc; b=BrVgMHhf6GHtewHqJoL4BLauWkJi0zXo45GyxOL1j0cdrN6fBKRJSfsw3TCSj7IH8eOPy1uIrpRmUsaRSRPeUY2IFYy5Xv6ngqzF8vExv3NhSxMwIxdu/HQbOONt5KS1QFgc8pMuqJgKridFe8dIknI+6Gey605Ef3cDb6doBj4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709137676; 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=axAQ7T8iEdxtdbf4VkKW5nP1G6BuWm3ajQSBrJDtGQc=; b=kCUZ3oaXj27VpxJiGRbx8e8oHS7prMawPnnJ1EU+FzrhxS0JlxS3yTGzOoVJRQnA0iuVCIsZuYznOvJs/1SU5e3zYOKBiQVAL/d55XLdXYIz2piuRQCL6a/mAmAgKzxv9Xfg/XI+r8Syn2i+2NsSihYWIOk9PwS54Z1Pwi88dAY= 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 1709137676504841.7372113703525; Wed, 28 Feb 2024 08:27:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfMjI-0004CT-Tc; Wed, 28 Feb 2024 11:24:24 -0500 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 1rfMjH-00046G-AQ; Wed, 28 Feb 2024 11:24:23 -0500 Received: from mgamail.intel.com ([192.198.163.7]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfMj2-0000pm-Oq; Wed, 28 Feb 2024 11:24:23 -0500 Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 08:24:06 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by orviesa004.jf.intel.com with ESMTP; 28 Feb 2024 08:24:03 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709137449; x=1740673449; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nxRQf/+tArZDzcPHPsrl+p0ECgQSKCEQqDH1Za5Mhjg=; b=K+25loYKHaed5kwLQKiE3hXX0RQEjDPb/ajDzxS3bNmPr7uzFrsNiTU7 aPgAukCE9+wNTkgj5R3hHuQp5m7fVTFeatk6sb/u8ovEx9FxBpNfGJnVz M516RIMm02GnqMhTSP0rdu28ss3I1xX8iZ3rCdviLLShF1l0c5K+0XTiz NArwfcFrImDhMONihh5eVMi33WwECEy8uw0TwU2ClznQbIOQZ3D8Ayy5e ojWv8/cQAEGIz8Vrx9wADW/wdyV8Hece1IS7WeOF+V/QOjsV3yat7Vtwl NQL089jcOmw1lrJ0bHzzZE7Ey2py7g8LoMX0ttcphcpk+ckon4fa5uoTM Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="28982478" X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="28982478" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="12144933" From: Zhao Liu To: 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 Subject: [PATCH 06/16] block/nvme: Fix missing ERRP_GUARD() for error_prepend() Date: Thu, 29 Feb 2024 00:37:13 +0800 Message-Id: <20240228163723.1775791-7-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240228163723.1775791-1-zhao1.liu@linux.intel.com> References: <20240228163723.1775791-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=192.198.163.7; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.102, 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: 1709137677080100001 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 the pointer of 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're 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 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 Tue Nov 26 07:43:07 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=1709137668; cv=none; d=zohomail.com; s=zohoarc; b=T/ugwZKgt2sqJcJ+Rc92e9iBXDK7sZJr6JGgbeHJOih1T9QdYTOdJTPPGY8pm48wxTwSF68WN5Ul9JwamMNIGI1Eau+/7CuzsUnHQuftCO9l2xyq+IyrONoPSEO64lO+t6EEgiTKg4oBei1J/T5XUOOgqRoiHU7BIUAbm6mkiDI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709137668; 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=NsPlA/brfj66fFZFKgIyeUFsw60Ejg9KqFxf9W2KoPo=; b=XXjCLN/3hWQkZ0WSk8au5hbCvW49MrBVArtM2yGh81/MmDniLp3q/TX90YNmaYYHxrzni29p1/8ivpCKY5kD5KD/4r4jCQPLBwdb1XNvPZXKPoJNanYVpQYa/FuSoLkvxeG3KbzsROEOuXl/hI6cbrEBCOuMt3KGC6d4DXNbRYY= 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 1709137668164566.1393076524441; Wed, 28 Feb 2024 08:27:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfMjD-00044m-Fq; Wed, 28 Feb 2024 11:24:19 -0500 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 1rfMjC-00044Z-Ll; Wed, 28 Feb 2024 11:24:18 -0500 Received: from mgamail.intel.com ([192.198.163.7]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfMj6-0000pW-Cv; Wed, 28 Feb 2024 11:24:18 -0500 Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 08:24:09 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by orviesa004.jf.intel.com with ESMTP; 28 Feb 2024 08:24:06 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709137452; x=1740673452; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jGURPkqjrDwg1BsnAyssk07DImLUmwhVmeLL3zPzs68=; b=lq+fAlTeSrEE07SN3XLPKQc/hC/D82jiZ2PHJIYXBe9/FCsDKqXUA469 1dkeBR3UBjgWZmCDzuXA1ssXIPSrjqh0h/rwIQ6Y8AAgEWkCBSS2Mc/pk GhnsXOwV/o1723mk9RVnjTW7oZuY/RrxT2hh86SBE5DR8oH39tFhcZnJq CFTbYyX82mDwc0k2F2+Mdt09uyFKKz31kEIGAkHd+RaY4rpcgtIBW9Gs/ rIOwT1vzF9A/r17BKPQldfMMS6jhh8yWrlONxNfRMDTUiDEj4TcY3iXf5 KUVCP1/NZyCjaVHT9bY4GInOrEfgo43Xn3V6ofdH1PGP3AJNG17wuIHcc g==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="28982503" X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="28982503" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="12144951" From: Zhao Liu To: 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 , John Snow , Kevin Wolf , Hanna Reitz Subject: [PATCH 07/16] block/qcow2-bitmap: Fix missing ERRP_GUARD() for error_prepend() Date: Thu, 29 Feb 2024 00:37:14 +0800 Message-Id: <20240228163723.1775791-8-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240228163723.1775791-1-zhao1.liu@linux.intel.com> References: <20240228163723.1775791-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=192.198.163.7; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.102, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, 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: 1709137668974100001 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 the pointer of 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: Eric Blake Cc: Vladimir Sementsov-Ogievskiy Cc: John Snow Cc: Kevin Wolf Cc: Hanna Reitz 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 Tue Nov 26 07:43:07 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=1709137495; cv=none; d=zohomail.com; s=zohoarc; b=VmEpP4dD5TijyNZ0glufmy6W5pr4NFxwcCtE3DoXEO+deLj93tsddjm9sfyOp9R0o/3sSBt7GagvRnJomYCE9G04ITBDxcZA+IoXKCtGCINScqcDdr/bWXBfL5rwRSxjbXOBOAehFVo48wERZJJZRLJTL5+GbBIzbptlDr8ZPGA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709137495; 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=XHwR4qKKSA1cX+DA6RN8Cfg0uuhay0TY7evli7aOSKg=; b=XAR/R6Op3rFWXuHZEAuPLMLqK98h5r1MlKcATNKC5ExyHqVB5Y0rLadIKaK6iGfoy0og5YrqSUpQ92+mZ7zf18QgjEaaNeYrpR5OgGugiZNYMgctWo72aUmczUckRhDDBiPDdP8jMPiJYAugPmXaj1XsZmecjGuxm26CL38d7iE= 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 1709137495307579.0870567852248; Wed, 28 Feb 2024 08:24:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfMjG-000468-4n; Wed, 28 Feb 2024 11:24:23 -0500 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 1rfMjD-00044p-V3; Wed, 28 Feb 2024 11:24:19 -0500 Received: from mgamail.intel.com ([192.198.163.7]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfMj7-0000qD-O8; Wed, 28 Feb 2024 11:24:19 -0500 Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 08:24:12 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by orviesa004.jf.intel.com with ESMTP; 28 Feb 2024 08:24:09 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709137454; x=1740673454; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iXzFvZO4SYHHRPae3tgl32srVdfSkIO4ExeRw3/c9WQ=; b=ScMpkj13eCn23ALEUAhnCzj/0zFaf2KgX6qKROVejgMzi1qvVlQ67Tfg 2nOEdCWVOV3XX4BKTWfhVzPClywaH+N7KoEzwnYkpAB69ZPHgPrn7V5Vi Hd4Wrh66/v+Q0L8b5GrVzl1dEP6aWIk/73iRzwOkE+WupPd7TxxJ8/Kmt D5xT//Dgz5ZKt0FCRj5Bk2c3pHM5g0LwmYjHb5rLqctPmOJJD4f1EeFPY JITZWckJp7VFasx20+F97LFgCkHZHd3SEY9zDfHDGfqaFrky8odZOEuVw WDEPVupxGIcPB9aRjL7gd9Uhth3+9NzlS5Nke1LZWg/wwd/RhnGCdyA8R g==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="28982518" X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="28982518" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="12144967" From: Zhao Liu To: 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 Subject: [PATCH 08/16] block/qcow2: Fix missing ERRP_GUARD() for error_prepend() Date: Thu, 29 Feb 2024 00:37:15 +0800 Message-Id: <20240228163723.1775791-9-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240228163723.1775791-1-zhao1.liu@linux.intel.com> References: <20240228163723.1775791-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=192.198.163.7; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.102, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, 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: 1709137496434100001 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 the pointer of 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're 2 functions passing @errp to error_prepend() without ERRP_GUARD(): - qcow2_co_create() - qcow2_co_truncate() Their @errp parameters are so widely sourced that it is necessary to protect their @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 Signed-off-by: Zhao Liu Reviewed-by: Eric Blake --- 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 Tue Nov 26 07:43:07 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=1709137623; cv=none; d=zohomail.com; s=zohoarc; b=dlnoKC/nNkWITaqRC8PBbSEyvQCo04JD7zaCtxAoxYKbAWphLYcLBs2+zrlwhj4OdcnYbybIqKrzz0QXsI2X0nqg/8zF0MGoLg7R8xUiAUxyxFZB7hU9DOZvvgCin52ivRfrCE2uj5Nv+yBbdA4spaw9hkafGzD3ZpzwggkDs4Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709137623; 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=k/NXowpsB/LTzV5wCJVRzMirb5Lbi36qN1VPhVnG/V0=; b=AgTVNWItg+G0gKTBP+P/R/uxfrjaLgsPlXZOV2TpoA1kMJnYfDQcRiddwh4qXP/Gm8GgIY4JDZM4NDYg0f9/RanM8XKxZdrEr+khsyzzNEDTMyJcSGzCt2nQZvSbW5E5WgwKCXu5Q/yc6ktyecSoLjBf6I9vlgkd61hEjBzZyzo= 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 1709137623928734.2141938970254; Wed, 28 Feb 2024 08:27:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfMjJ-0004Hl-M8; Wed, 28 Feb 2024 11:24:25 -0500 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 1rfMjH-00048C-MN; Wed, 28 Feb 2024 11:24:23 -0500 Received: from mgamail.intel.com ([192.198.163.7]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfMjG-0000pW-3n; Wed, 28 Feb 2024 11:24:23 -0500 Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 08:24:14 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by orviesa004.jf.intel.com with ESMTP; 28 Feb 2024 08:24:12 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709137462; x=1740673462; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jgSKdh1K5au4hr9TGsT75o/2HJxQJ0BlN2wKDuJibyk=; b=WYlMfss23Jt0+0mn9oH0PUZYnzXwyA6P5Bv9HRQAlKK785+hx1HWcXvo VRqmpxrYBqIzh6ALbPp+0EJ878dIjMCSDYwFGi8l98USZs1shieCgRZU7 SMxKiNmJ4EkdXSNwbTf9FnDVa5ep5hFognHPHG1ZjETNl7R1TvTweXZ9M Z9QZwDNB/mJyuJEQYM0CV0iBErfDlzZDdDzUwB5JTX2LqRSRInVLJQ0Et JYK/g6tlhezl1fD24NQM/lRceAjHqQbL85Xwu/W7CabpTr0jhvKzEoysX XhUWxl8/Lvcjgef/v4Cm2zFHKjtf2gvJVQbscb7bUjQOxe6dyJFqItwkZ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="28982542" X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="28982542" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="12144983" From: Zhao Liu To: 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 Subject: [PATCH 09/16] block/qed: Fix missing ERRP_GUARD() for error_prepend() Date: Thu, 29 Feb 2024 00:37:16 +0800 Message-Id: <20240228163723.1775791-10-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240228163723.1775791-1-zhao1.liu@linux.intel.com> References: <20240228163723.1775791-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=192.198.163.7; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.102, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, 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: 1709137624852100001 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 the pointer of 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 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 Tue Nov 26 07:43:07 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=1709137510; cv=none; d=zohomail.com; s=zohoarc; b=QunbikTYPGpltEMsj7jzsqCx4Ym1MybthjVd16f1baMoNaW0rsp30VgsMIV2iInN6kYlwxbAUaGKbFIJJ2sa7fkIw6uoMuA3zPc2IsoOfCjPK9XmuUQTm5Y1PViNPD4m1CB/UG4cfwKr6O4kKuXL4ftukx5tBhyf2TckBKM/C+w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709137510; 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=Wbx9vyko/oKOZJgjRMMpPbvpeLnPHPbveBL+ljQt4co=; b=bof0TlYxEAm7iLydnhRyOVKaf6H+7oYRVFP+00Tx3lyc4JxnJaBJDhKawzonISOWsQrst64XxTP4xHHIIyY+hYxDE33yWPxsb8lciyTVams5SuZpinIIfnMprKrAYdmll3zPhNcii18MF8qGCgzfHyWRAQ1xEUT4U+IIK+ksmbk= 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 1709137510408935.6632649746845; Wed, 28 Feb 2024 08:25:10 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfMjM-0004PC-H2; Wed, 28 Feb 2024 11:24:28 -0500 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 1rfMjK-0004Lu-Ip; Wed, 28 Feb 2024 11:24:26 -0500 Received: from mgamail.intel.com ([192.198.163.7]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfMjI-0000pW-P6; Wed, 28 Feb 2024 11:24:26 -0500 Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 08:24:17 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by orviesa004.jf.intel.com with ESMTP; 28 Feb 2024 08:24:15 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709137465; x=1740673465; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=f4WdEAP88HmKKD0w3J+So2kEwEw+Dq4DuWbImglfdPQ=; b=Wcp1pmAWeS4d7W36MO4DVARygOfAtOHVLwaHCI0q8Vd1Av9W3E5jkFW5 lTpKFgolRW65UHZ+kNxHQ8rohY4Prc9qK+lv856aQcNc2mNAZrefXKAOr RxfAWV9hkAiZ5KQZRWwXEBIdW1elXKcdUaaCRdfgRGh1wwRvPWI6INDin lsmj/ak4F/5PUydJqXvRRQaKuEA0evJ42XRr7C1UZiP9GD4wdKyAm+fgz tP+OQQ0mN8HTMv4pep3ilXN54V4F63HaLR91DTeEzVD9EJyIlZuaq1LTL +1Z83ySvvsVs4Rrg48uz5vuSJG8GoY4ZI0XbCkAn/S8qLUkfGC/V7EwS0 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="28982553" X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="28982553" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="12144995" From: Zhao Liu To: 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 Subject: [PATCH 10/16] block/snapshot: Fix missing ERRP_GUARD() for error_prepend() Date: Thu, 29 Feb 2024 00:37:17 +0800 Message-Id: <20240228163723.1775791-11-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240228163723.1775791-1-zhao1.liu@linux.intel.com> References: <20240228163723.1775791-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=192.198.163.7; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.102, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, 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: 1709137512451100001 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 the pointer of 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're 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 Signed-off-by: Zhao Liu --- 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 Tue Nov 26 07:43:07 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=1709137531; cv=none; d=zohomail.com; s=zohoarc; b=gRWM5Ox5YPJxd4v5+KpaSVq4QxCy3jszuDPXoDXIDScGDUklqiP8ufA3xrNPC3wtK8eeCsdiPnenKUDJZHub7rlqtrXn8qrb6StCv+UebN/05+zw8l31xVc+HlVWoGHAnd4G57Tj/F7ttez+SUOGhlGYqePAwpaatGHYZw+1rsU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709137531; 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=Ot9R/ybWhucs1vYoxlYCamAhJZHz2Saz5K2xfPemjHQ=; b=aGnvLjHw/ipo3M8wJCIj/fF0Z5mj/x/gXB8p6L0PRabLXhWzfScBdOXPRfx/tvr/rQejEWpr4AWc37W5FEtXtrWom2siU3IOfa8CyOWDFgWzSdN3hruHWs5g2+Wqv8c/psWO76DNdxLgTKXrVYLbWkdDeFh2+h+F2F6KH8eJWfM= 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 1709137531233211.0453883147136; Wed, 28 Feb 2024 08:25:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfMjN-0004Q4-5F; Wed, 28 Feb 2024 11:24:29 -0500 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 1rfMjL-0004OJ-KW; Wed, 28 Feb 2024 11:24:27 -0500 Received: from mgamail.intel.com ([192.198.163.7]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfMjK-0000sx-1T; Wed, 28 Feb 2024 11:24:27 -0500 Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 08:24:21 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by orviesa004.jf.intel.com with ESMTP; 28 Feb 2024 08:24:17 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709137466; x=1740673466; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=se7iaBg2YM4bDU1t5iF+ZzwdJjnzwm4fgLQ2Wyzhwuw=; b=fLlY9V60XoY97Z0P/0LFl5zrFdms/IFU7sIsHh9Dztd/59Xgp99N4sfZ rU6xtecXRoH5AyUm9TR31lgel3ySDuiMp5qjYobr/2sgnaXydIuAYaZGQ 3CnQ2EPnRRxH1/P4ro+YMWpdGDpqg3MmvsfKKMGycNm2WdiM7+DIyaG6z JgAblhc59fImAIZ2I4pKvSP3LrwqqGbYDietLhEUiablyFuT2usikrSTz Qfi/VPylQJB9UvmLDPF8sOlXzT0j4EZ3hndj7nnIpex8XdS6ExjuXF2fn CWT0M4UiU3aC1QMVE0QxpI3iKFmy+r21te8kmhvkSDZAoKtTQURQXL6/F g==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="28982562" X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="28982562" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="12145008" From: Zhao Liu To: 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 Subject: [PATCH 11/16] block/vdi: Fix missing ERRP_GUARD() for error_prepend() Date: Thu, 29 Feb 2024 00:37:18 +0800 Message-Id: <20240228163723.1775791-12-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240228163723.1775791-1-zhao1.liu@linux.intel.com> References: <20240228163723.1775791-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=192.198.163.7; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.102, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, 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: 1709137532706100001 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 the pointer of 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 Signed-off-by: Zhao Liu --- 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 Tue Nov 26 07:43:07 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=1709137645; cv=none; d=zohomail.com; s=zohoarc; b=JQuuDdwQNW7TbmVuRNrHonhoWgDpI8ZM2r2OItbLYZ7jsW5/tm3au+/1BEeDrEdwNR3ELxowftrtz63LwBEnIX+SHTemD2IyZ6sXpFfqZjOP8c2q6DOtRhdhPIPYpD8L08rDhEyCBhMNygVmK67036IUYvPbMpfPirPtWsQOT20= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709137645; 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=qcGiO1g31jQGmFd6ns4H7pnBVD68fLGumjMlJD9jluQ=; b=MjSPEaQ28TzvrjI4omKSdrYn0QTvu6XMkktdSfF1W/ZouwPMLWRUlhSAGPsj52aMjXbpxeVPCdLvEK2PGJ4P5tgIyBq/1AFVAuho+9vMKpTGVKRRzT1Nv22Lg+JBQPmEP8A2BZ6O06jJf4/lWL+5EmusqWWeqV8XMGp5l4I5of0= 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 1709137645140433.808628508345; Wed, 28 Feb 2024 08:27:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfMjW-0004i2-Bt; Wed, 28 Feb 2024 11:24:38 -0500 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 1rfMjM-0004Q0-V7; Wed, 28 Feb 2024 11:24:28 -0500 Received: from mgamail.intel.com ([192.198.163.7]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfMjL-0000pW-By; Wed, 28 Feb 2024 11:24:28 -0500 Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 08:24:23 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by orviesa004.jf.intel.com with ESMTP; 28 Feb 2024 08:24:20 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709137467; x=1740673467; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bf/R70ToG/GS2DWSCokskMMh3cdw5G5KJa0QQxj8uYs=; b=lqe0VGgOATGWOMfnPEZ5EWgYbaaJrr6Nu5+9uNM+prZie+kRW4FwK8LN fyai2tNng58VL7WLaXKK4dOFU0sWWqsx/GP4E0Sqna/nY6vkIh6ePKyuS 8n4Yg2jj4SYlIiIPdq2AKgsQfAIWfk33XJK2C0K3SVoG8dRHfASx6f0Kt 0/yaRc6phAdHz+3r0ULkr3HR38QAuATj1e0nYWKPY+RF526zChqI1+2x2 zxuAfnVgGICPM/nPI5sUeAebXHpL5mkX0s4zW4qyux8fYjWKbvaoKuByc lQiPihpgVjlzdC6e4ldglgLIQt3BIWpOKmvpnT+4mfygnjFMfYonMovWx A==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="28982596" X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="28982596" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="12145026" From: Zhao Liu To: 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 Subject: [PATCH 12/16] block/vmdk: Fix missing ERRP_GUARD() for error_prepend() Date: Thu, 29 Feb 2024 00:37:19 +0800 Message-Id: <20240228163723.1775791-13-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240228163723.1775791-1-zhao1.liu@linux.intel.com> References: <20240228163723.1775791-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=192.198.163.7; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.102, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, 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: 1709137646897100003 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 the pointer of 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 Signed-off-by: Zhao Liu --- 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 Tue Nov 26 07:43:07 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=1709137725; cv=none; d=zohomail.com; s=zohoarc; b=dHFlBeIY3jgeaNB1qaxgxf/zcMKTk8aCA82GJnJ+/spVQ/l7rvpQ9AaLa2SiQ83E6CTM1XN1/kljlctTU5vnNC9AEMY9UKAa/2Nv1u3wqMYGIlIzoiXqHNeDHXf1kvkM16DaXYdkvJ0oOe4siS+daPwcJCU9pu9FqPEZ2OyKHq4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709137725; 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=wspOpwJOxnQyU+qBkbHParDRnBXFPkNlNQI5wlxW9Ps=; b=J9G/IwwNQdEcy2q9KUKmdHrSwlb8O5S7qw2js+tlJahNYk7y4byiv2rKZNPo77HbrnKAg4LEQU/2T5AhLoLBRlHLMnU9ZR89U0ggXPFI5fzDEFQ1vixYHfwdpFWQcooaZ0X4roqadt6LS0ErJGuKsyQeH5yCxOtfTN/BzU0I82A= 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 1709137724635334.17287673556086; Wed, 28 Feb 2024 08:28:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfMkP-0005bn-3P; Wed, 28 Feb 2024 11:25:33 -0500 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 1rfMjk-0004rE-Do; Wed, 28 Feb 2024 11:24:54 -0500 Received: from mgamail.intel.com ([192.198.163.7]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfMjh-0000tl-R6; Wed, 28 Feb 2024 11:24:51 -0500 Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 08:24:26 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by orviesa004.jf.intel.com with ESMTP; 28 Feb 2024 08:24:23 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709137490; x=1740673490; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0VXCESuW/e9yfAOjpOzB9OfyII/TeKhI92xZVW05FYo=; b=E4auvvwGr6xWLZqWbOvs+WwHgq9w0ptPpNNN+tlVxM1rDGyV72uaaLZR XS1iKU/LfWLyUufdoLEZMoum6jBf+oQvufJ44O0SK1MD7cKAzJFg3+/L7 H9TpYsTLmNGUSAnKe4YtUPE6LOkl4q53tT2Q5O8/MEpvr4sSvx8MG3Aw9 SP5qbL6GaJvXmeMNFZ1aLkBNnEL3UcESK1Ft3YmsdWvJeImIu4C1HwLs1 JRINTb/Ue4OhaR/Miet5EgErzmYt0su3ijYHh4k8kGlVMSTFqMmz6Qg2f RrXyV+5MvbAoI+7btnGzHNTL1oia5DARt7lZY4XRD4RvitjIN+7g0RWXv g==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="28982624" X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="28982624" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="12145043" From: Zhao Liu To: 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" , Stefan Hajnoczi , Kevin Wolf , Hanna Reitz Subject: [PATCH 13/16] block/virtio-blk: Fix missing ERRP_GUARD() for error_prepend() Date: Thu, 29 Feb 2024 00:37:20 +0800 Message-Id: <20240228163723.1775791-14-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240228163723.1775791-1-zhao1.liu@linux.intel.com> References: <20240228163723.1775791-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=192.198.163.7; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.102, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, 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: 1709137727126100007 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 the pointer of 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: "Michael S. Tsirkin" Cc: Stefan Hajnoczi Cc: Kevin Wolf Cc: Hanna Reitz Signed-off-by: Zhao Liu Acked-by: Michael S. Tsirkin Reviewed-by: Stefan Hajnoczi --- 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 Tue Nov 26 07:43:07 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=1709137658; cv=none; d=zohomail.com; s=zohoarc; b=Ris/fcHwLNR0EEvIjvyKXErL6xICPNZ3D2xKBf/OeYQmS+tKkjatRQgCbyEnLAqrouilVh4nVDMBjH2XLlN+YNT5pXzVqrTOTSj4yPd/EXlJAoP9CCYgvUtJZGkBb2Aq4PL+7sSdxQIBlURtMKe23WzbxO+GVRSn0QUvdcZAIC4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709137658; 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=bPCru3mweZpr1+ush2HjvKRmqvmE03VqpCjkEskRANo=; b=b3eaSaVOylwLkZRC5pZhRq0xcMCS1qX/qH5t/tseB4P16hkXYWv1IbMCoB6OAOO3ShpYokvnXWaNX7ABWpUJ9cYuPHzerVE8/JAbbImD6oHzomws3kEyXSPUBV+X7eN4xqPJS/TSmLqI/u9bkBOxkRVaK0E5PEob3Nk3ogwHU/w= 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 1709137658712197.63795017818927; Wed, 28 Feb 2024 08:27:38 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfMkR-0005jW-D3; Wed, 28 Feb 2024 11:25:35 -0500 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 1rfMjk-0004rH-Iv; Wed, 28 Feb 2024 11:24:54 -0500 Received: from mgamail.intel.com ([192.198.163.7]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfMji-0000pW-HX; Wed, 28 Feb 2024 11:24:52 -0500 Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 08:24:29 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by orviesa004.jf.intel.com with ESMTP; 28 Feb 2024 08:24:26 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709137490; x=1740673490; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YUV44m5264ILzslR7yaaWtbghS0W7xiSkmi7/Bp3aow=; b=dxtrKqLtGE+Qt7M91B8x8TxBymHTM+pVKmbawvbegrGh+LIzVOpf21Qk gmTbwQ3bqc4JF7vJ1dEJRfwQD1oQMoC8pj/sU+zWvE1T6e4ZNppU9XYaW zfewZPEWZeP1GBaTAgzPyVlqH33/FwiwavFSIv9pk0XeUTANeeSbpSB1T X5g18ZiSxfhSUlmNOQa8rR6qvI0b/TgpCH9soLJG35vvC1dBHVmLOpfa2 EtQK9ZBcl2mhZzfhi6hqzwI9SqT6Xa+UB35yHS/9gp59XB3HTsIKMIvw5 OJAtl3jMF2iZqMK+8h/wtzPfnT51br0zpYu7itxdVHCnhjLJBpxBs6iiL w==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="28982634" X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="28982634" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="12145054" From: Zhao Liu To: 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 , Stefano Stabellini , Anthony Perard , Paul Durrant , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Subject: [PATCH 14/16] hw/char/xen_console: Fix missing ERRP_GUARD() for error_prepend() Date: Thu, 29 Feb 2024 00:37:21 +0800 Message-Id: <20240228163723.1775791-15-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240228163723.1775791-1-zhao1.liu@linux.intel.com> References: <20240228163723.1775791-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=192.198.163.7; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.102, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, 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: 1709137658929100004 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 the pointer of error_fatal, the user can't see this additional information, because exit() happens in error_setg earlier than information is added [1]. The xen_console_connect() passes @errp to error_prepend() without ERRP_GUARD(). There're 2 places will call xen_console_connect(): - xen_console_realize(): the @errp is from DeviceClass.realize()'s parameter. - xen_console_frontend_changed(): the @errp points its caller's @local_err. To avoid the issue like [1] said, add missing ERRP_GUARD() at the beginning of xen_console_connect(). [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: Stefano Stabellini Cc: Anthony Perard Cc: Paul Durrant Cc: "Marc-Andr=C3=A9 Lureau" Cc: Paolo Bonzini Signed-off-by: Zhao Liu Acked-by: Anthony PERARD --- hw/char/xen_console.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/char/xen_console.c b/hw/char/xen_console.c index 5cbee2f184d8..683c92aca1ce 100644 --- a/hw/char/xen_console.c +++ b/hw/char/xen_console.c @@ -206,6 +206,7 @@ static bool con_event(void *_xendev) =20 static bool xen_console_connect(XenDevice *xendev, Error **errp) { + ERRP_GUARD(); XenConsole *con =3D XEN_CONSOLE_DEVICE(xendev); unsigned int port, limit; =20 --=20 2.34.1 From nobody Tue Nov 26 07:43:07 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=1709137697; cv=none; d=zohomail.com; s=zohoarc; b=UOzEcLdCBN+88dHxYReNeGbgS8L4KgrImqJANhxQskYa0Cw1Wk1vHGAvq19rKlVOieFP/+xs7xUti7Xaa9XhwMkpLD7e9qacJeQnolPLF2Ml9aAmt3fcfe7aIApW0UzS8G8LFMNAwdDCNVD2i6y6qnhPi3jhL3jkdCUvw9lcXE0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709137697; 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=aGavwMgnRJ76wIVbjgpGQmo5zVUmoipBfHrmJH3J95M=; b=BUcmktwHMnw8eCqQuBPU6WvecN/wB4g5vUwm4Y8crBz76ZIyk7bwwSKx6xiZmraqYS+CB0yndGcihUcAKCqNB61nI+hoKGCOnfQ4OOwROsox3Emp01FN3tcUsa3FhORACWF79evtPDVqQNt4zghYLgyU6l8ApYtj4AT3cdbI7aI= 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 1709137697201862.0112902981367; Wed, 28 Feb 2024 08:28:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfMkP-0005dP-IA; Wed, 28 Feb 2024 11:25:33 -0500 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 1rfMjw-0005Ag-Iq; Wed, 28 Feb 2024 11:25:07 -0500 Received: from mgamail.intel.com ([192.198.163.7]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfMjp-0000uO-3v; Wed, 28 Feb 2024 11:25:03 -0500 Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 08:24:32 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by orviesa004.jf.intel.com with ESMTP; 28 Feb 2024 08:24:30 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709137497; x=1740673497; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=F1IuRZawaJ2NHOUI3QO3od9jdb42E1bkkqWXt4qynek=; b=Yr2MHjt31e0PPo/mPj1/oZfIRMud2o18iJr2maeTNRLZ9LDQCgyStmO4 n5XznHl/FiOOC+RLLOdm0BofRPZE+W7ago1eu0pf++61c92KIUH20qBCn 6K/sA4rYq50WC6R1wNa2jV6NpM7iy6Ea1e3oJLHjUbWQPN2QK4eqfWJTL 6vEgFE1Tx3AlCzQixj45WPn1sjhQRQGsx8N5aafqj4p6lrresnfK+ny7o nAfvhMgGQgyFsw48yITE88b4wzDdP2ARmhbkya8sR6H7et9nXKczQgy80 Tybitb1grGoiwFdYjKIByuh66LHkAxQiRdr6Rncd1n6nw/dsm7AaS7184 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="28982649" X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="28982649" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="12145073" From: Zhao Liu To: 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 15/16] hw/core/loader-fit: Fix missing ERRP_GUARD() for error_prepend() Date: Thu, 29 Feb 2024 00:37:22 +0800 Message-Id: <20240228163723.1775791-16-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240228163723.1775791-1-zhao1.liu@linux.intel.com> References: <20240228163723.1775791-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=192.198.163.7; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.102, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, 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: 1709137699070100007 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 the pointer of 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're 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 Tue Nov 26 07:43:07 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=1709137689; cv=none; d=zohomail.com; s=zohoarc; b=jvp3HzPOVqWVHc4tBtn2qhJY0ykFhg3QwL6pgMcW5eP4tjN2qrERn+qfNlccpwIyYuiDsa9rTTBmw31Uqr5xdmXTjdbI/MFpRWIEsLBd1Qfy4AQvDRw504m9i50Sz0g73FY2IJMVW6TuBJqondMRFGEKaQnfbSa9REIpQGGdErs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709137689; 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=IX365YNZKfplEP4nS8CfKxDE2K4CBqnnktMdNr0p63g=; b=i9wYfuXbK8qf266fRwJZBLC1SdKUo6+3V2qXs0tVeTerTE6Vuv8ai4sXFKCfmmTOLj0nFyAobzQNofrg1FoEflu6Cqu2DthRwYOd+5xGx1r9yV9NBbUZzWDCcJ4HMNxSSqwLauktPiyp60k0ex1qhm9ERP6xqthY/S9/DJLljCo= 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 1709137689051675.2151894268725; Wed, 28 Feb 2024 08:28:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfMkR-0005mY-Nk; Wed, 28 Feb 2024 11:25:35 -0500 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 1rfMjo-00052N-Ou; Wed, 28 Feb 2024 11:24:59 -0500 Received: from mgamail.intel.com ([192.198.163.7]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfMjl-0000tl-AM; Wed, 28 Feb 2024 11:24:55 -0500 Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 08:24:35 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by orviesa004.jf.intel.com with ESMTP; 28 Feb 2024 08:24:32 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709137493; x=1740673493; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yMTWaY/sS/jyModr1jZtevzt+KtVPqAcOTyAOHQmGhc=; b=MsDeTrYOk1f0O8EbDbJG0toC4GHUlZks3ydNCVt40NKsdTRDUdBRqSeq 82gUNV91L0WjHBbaakwgOsW5d7CV8A5Wp+0TTvcWSOltfQlaABBhRUtXs E76gIcxheMACrxzVyrkSXRMzwflJKKrAdRcpOe/Bap7oC2p8ePZO00OaV 7s7coDEbIn3H918MhFE82ORSJ3X0CrY1bau+52doXZCfgMeQS3kKwOuon Nd2STrOSioFDH9bvt32A4J4UQIB5YXLHWjRklEXVCskDwYvJzSGnMHrv/ GKTJtRl0kRVTQ9181TGsrwGGTura+FzMfMJjL6c1m6PS3YjpoIkJeYkLD w==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="28982663" X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="28982663" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="12145086" From: Zhao Liu To: 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 , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost Subject: [PATCH 16/16] hw/core/qdev-properties-system: Fix missing ERRP_GUARD() for error_prepend() Date: Thu, 29 Feb 2024 00:37:23 +0800 Message-Id: <20240228163723.1775791-17-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240228163723.1775791-1-zhao1.liu@linux.intel.com> References: <20240228163723.1775791-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=192.198.163.7; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.102, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, 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: 1709137691053100003 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 the pointer of 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, the @errp passed to set_chr() is so widely sourced that it is necessary to protect it 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" Cc: Eduardo Habkost Signed-off-by: Zhao Liu Reviewed-by: Markus Armbruster --- 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 1a396521d51f..545c3ceff7c9 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