From nobody Tue Nov 26 06:25:32 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=1709216781; cv=none; d=zohomail.com; s=zohoarc; b=dAMz6ed6tdh0Txt7I54adnfvIVd2TZEVDCSWQGAUZsmjcnNAFVWiDrNR8waFn+VHiQAcrxYtKlQ4itVWJvBbTHbAgG+zPSt8vasIp1bsGNA1/htEdPG/tpGiMkDIJN7Iz7B3M+ZcGcKQxlmbBQL7rWz6IhxX4T8lu/N223sOGrg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709216781; 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=OTKQq8u0G+ZUcwUFsnc9adUG2YL7cUlpDF85cljHrFE=; b=Kt4KNJL4shMYFdArl3UJZrJCy4eUG4Vnyf7NyehQSmA7OZgBdGIY3izEJt/ysL9yOSo1RzxUe5GLrU9ir53XytExnrB21EUtQnWUScncFXqh6Eu+k7j7Ah1RDV41ylzKwet8xB6tgP9r1qus6tpGj+I4+NJv511djeTcJCAELL0= 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 1709216781336442.93289897197894; Thu, 29 Feb 2024 06:26:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfhM5-0005wF-2d; Thu, 29 Feb 2024 09:25:50 -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 1rfhLy-0005vM-DP; Thu, 29 Feb 2024 09:25:42 -0500 Received: from mgamail.intel.com ([192.198.163.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfhLv-0005OB-NM; Thu, 29 Feb 2024 09:25:42 -0500 Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Feb 2024 06:25:37 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa010.fm.intel.com with ESMTP; 29 Feb 2024 06:25:34 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709216739; x=1740752739; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/FOMjXZewsc+joBIJ6M4Jgn+QHL0sPsnLHD+cs/NNWw=; b=E1ZuINaeyfJZKiRmACM1Jmax8Wwoir2x++0qKxOgDkC6cYbXZQtpkQoo 62k2CKctOxlXRCnhToIvKlMw6UJPEBKTQsf3KTn1/vJQp2kByIdQawQvM utykZE+ohxAoQmbhX4WWkeXA29Es7Mvo4tbAyMiqtlY5uDmz355FKdyQh 9x7RZT/sLXMbtTPDz2+uKp4aEnZgn7wRLEewaP6pV6PmqXL+kQ7hpTyOP sc9wwBrH/rBmrUzkQRbFmHkEf5rSjXiYHekQSXPJCIxxyZUqGLkgSY9kN YpFXylRR2L7AxYt6x/5M0l3WyzrJ8KBC5xQLZSuvQAa2Li/uz2nO0PnIH A==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="14322720" X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="14322720" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="7793789" 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 , Juan Quintela , Steve Sistare , Michael Galaxy Subject: [PATCH 01/17] hw/misc/ivshmem: Fix missing ERRP_GUARD() for error_prepend() Date: Thu, 29 Feb 2024 22:38:58 +0800 Message-Id: <20240229143914.1977550-2-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240229143914.1977550-1-zhao1.liu@linux.intel.com> References: <20240229143914.1977550-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.11; 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.096, 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: 1709216782752100001 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 ivshmem_common_realize() passes @errp to error_prepend(), and as a DeviceClass.realize method, its @errp 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: Juan Quintela Cc: Steve Sistare Cc: "Philippe Mathieu-Daud=C3=A9" Cc: Michael Galaxy Signed-off-by: Zhao Liu --- hw/misc/ivshmem.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index a2fd0bc36544..de49d1b8a826 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -832,6 +832,7 @@ static void ivshmem_write_config(PCIDevice *pdev, uint3= 2_t address, =20 static void ivshmem_common_realize(PCIDevice *dev, Error **errp) { + ERRP_GUARD(); IVShmemState *s =3D IVSHMEM_COMMON(dev); Error *err =3D NULL; uint8_t *pci_conf; --=20 2.34.1 From nobody Tue Nov 26 06:25:32 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=1709216792; cv=none; d=zohomail.com; s=zohoarc; b=jLXt8HPmA2sB7oeTdYSHO+2gV1csmIkVItQcvq0ehlwSCkIENJLuIzd9kA2GLs89wjIdf9/98O0xpoNMFKgFVaWlUZp52/0YnRrWebmlYlv6DkvKwN4gxuQ2JY/H1MqOjnLawz90hJJ3+2i+Uer4Cgd8hknnTRKIcNaC3mEhw0o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709216792; 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=YJ4gmPG8QqHO+MrcPM4kEGsTPgGjCC3bY85JGKeGS+g=; b=QPSKc1bf1e3iT8fwW8fBDtPu3A5gGytslDpHIijaVEHTBj/YoyR4mxanHANjtdom+kr3nRWPymnulZf768NThIANGSKHpMl2YXHR+p1OnfdbQkbH0WK3sgYx9TMRS6bv6ijZK4e+gupRSAuoWDDGMtq34XD5WJhhuMxvChwh004= 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 1709216792340820.4256457923816; Thu, 29 Feb 2024 06:26:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfhMB-00067g-RJ; Thu, 29 Feb 2024 09:25:55 -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 1rfhM1-0005w7-94; Thu, 29 Feb 2024 09:25:47 -0500 Received: from mgamail.intel.com ([192.198.163.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfhLy-0005Qn-J7; Thu, 29 Feb 2024 09:25:43 -0500 Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Feb 2024 06:25:39 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa010.fm.intel.com with ESMTP; 29 Feb 2024 06:25:36 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709216742; x=1740752742; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PVIcgcS+qmBfDxKXsQgehBX6G6DcMEFwCkNyJ4e5d10=; b=RP7xos8PdLKR8vnKDcAuSL1J4Fw+L4xyXCw7dDM4Ttd01mIgxcsLh0xs ZEjZv/WV2fFNzsbL5pCHzY2LCZWbhSJ6voORmxr2dYnK06WNU2jdNTSMU +b1QCv/e+Gjf1xW29SvgTwpWMSTuaOTnEkJwXCIu2uUKrKWmtTxrx2d68 G+KD4/3EckLlxe7CkUxnYMBHQKpvH6ocOiMstDzecsDgKAB4gKWFZoAAp dTYP3yKoGlMBBhWaHrBcpgheMqcg7ALrXhR2g2ihGXLeD1Hg8lxGIW1e6 6DxfGCgeM2PfAjSafC2F2PuWp+KVxFFLfUTEgo07W/at/HWbKkrhbUpUd A==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="14322730" X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="14322730" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="7793798" 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 , Jason Wang Subject: [PATCH 02/17] hw/net/xen_nic: Fix missing ERRP_GUARD() for error_prepend() Date: Thu, 29 Feb 2024 22:38:59 +0800 Message-Id: <20240229143914.1977550-3-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240229143914.1977550-1-zhao1.liu@linux.intel.com> References: <20240229143914.1977550-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.11; 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.096, 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: 1709216792763100002 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 xen_netdev_connect() passes @errp to error_prepend(), and its @errp parameter is from xen_device_frontend_changed(). Though its @errp points to @local_err of xen_device_frontend_changed(), 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: Stefano Stabellini Cc: Anthony Perard Cc: Paul Durrant Cc: Jason Wang Signed-off-by: Zhao Liu Acked-by: Anthony PERARD Reviewed-by: Thomas Huth --- hw/net/xen_nic.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/net/xen_nic.c b/hw/net/xen_nic.c index 453fdb981983..89487b49baf9 100644 --- a/hw/net/xen_nic.c +++ b/hw/net/xen_nic.c @@ -351,6 +351,7 @@ static bool net_event(void *_xendev) =20 static bool xen_netdev_connect(XenDevice *xendev, Error **errp) { + ERRP_GUARD(); XenNetDev *netdev =3D XEN_NET_DEVICE(xendev); unsigned int port, rx_copy; =20 --=20 2.34.1 From nobody Tue Nov 26 06:25:32 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=1709216787; cv=none; d=zohomail.com; s=zohoarc; b=Fj9NpRT8tnYpuc6rowLp/ma0pba72Py2QR5FGlB9Z3q/KAFzv4/OmmguLmgrTMMdIftrzDKvhtfZ8PlUu1NrEZyXy2rCaWFb9pz/i9+E5xKV/PgsAdcR/qfM63rUtCPWa3vc/oqcJHtBOC02pYJyjUf1b1dQ3pfy9kqAe7LLEq4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709216787; 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=MqAbUYdaJ6xvRcpDDGdNkleU4HlX9w7oSZenL94jtAQ=; b=PLny2kfxmQoIKpDRevNeSIlNPXqENIhnAJ1E3Getdod5OnbsEV3pcbvTS/irfMTnHslxMGsDEtyHEun7E5If9OEt2tPdv1jTQg6tD3Doz0xgLh38zlvcfU1nWfCPSn9MA7WTlMBRCPTAbAA+qTf/O6LH2CmaP84gSVDJq9E2nuw= 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 1709216787379461.2727259323617; Thu, 29 Feb 2024 06:26:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfhMB-000676-AG; Thu, 29 Feb 2024 09:25:55 -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 1rfhM2-0005wM-HC; Thu, 29 Feb 2024 09:25:47 -0500 Received: from mgamail.intel.com ([192.198.163.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfhLz-0005O2-1V; Thu, 29 Feb 2024 09:25:46 -0500 Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Feb 2024 06:25:42 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa010.fm.intel.com with ESMTP; 29 Feb 2024 06:25:39 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709216743; x=1740752743; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Vhw4H2qazZXZnap7nSADMm3siBGa2at5w2Ed72IArQ0=; b=f8mDf+9PIsyFFCVpotOqZWQShhwl4PVvCRqFQqTBpJwpsnWAyFA8zjnP VEXWXYrGItYDV1lmy9ORdbaVkuTt/DSnypfhGlbMmCgUJQLbuK2nQe6fz BhXj2FO3aZi49tDY2GJHj2TfgHCrvLRon09r82jUPJB1HHUz6+mAyGJTA 0cOUJFgSMSUGk0OjwcTS7RkjWuWHun1XZzrNO1xmLq7bBldb/b3r8fRrQ UOZwtFyqUxbcqgjURxDuuuH5mdo8ad6QN2pGz3adFihAtBQYIrcP3Whxd ycsbXdibNc7PTf9N74eYkT+pb8kbnZy7eq5NfNed1pPabKyL24HCxnpbn g==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="14322740" X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="14322740" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="7793808" 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 , Elena Ufimtseva , Jagannathan Raman Subject: [PATCH 03/17] hw/remote/remote-obj: hw/misc/ivshmem: Fix missing ERRP_GUARD() for error_prepend() Date: Thu, 29 Feb 2024 22:39:00 +0800 Message-Id: <20240229143914.1977550-4-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240229143914.1977550-1-zhao1.liu@linux.intel.com> References: <20240229143914.1977550-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.11; 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.096, 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: 1709216788793100002 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 remote_object_set_fd() passes @errp to error_prepend(), and as a PropertyInfo.set method, its @errp 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: Elena Ufimtseva Cc: Jagannathan Raman Signed-off-by: Zhao Liu Reviewed-by: Thomas Huth --- hw/remote/remote-obj.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/remote/remote-obj.c b/hw/remote/remote-obj.c index 65b6f7cc863f..dc27cc8da1f3 100644 --- a/hw/remote/remote-obj.c +++ b/hw/remote/remote-obj.c @@ -49,6 +49,7 @@ struct RemoteObject { =20 static void remote_object_set_fd(Object *obj, const char *str, Error **err= p) { + ERRP_GUARD(); RemoteObject *o =3D REMOTE_OBJECT(obj); int fd =3D -1; =20 --=20 2.34.1 From nobody Tue Nov 26 06:25:32 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=1709216941; cv=none; d=zohomail.com; s=zohoarc; b=BLwsSqcuM/gJtyyZ2p7DTKAbzBBvo8WSEj7PkWyGL4Vr/f37ZrCGZI1j3qQtc6K2E6vHhR5COuNdopCWv8Pdz1X5OR1lbOw8ZO0ddYf+dhFNXHFss9XnNY8KFYPpTvsebv1I6Z+UF8EQdCKhlqjuPEvxLfqL3ewUOMAqQt9ed00= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709216941; 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=2iAecHnhyCtpIcP4jpjdgZ1PeMmVWDceO1kTugbojQc=; b=KsNHmTt+ztiL624QSjK4kQgMHGFK38XqzQDBDShdXdoij8czAPP0Q2xPYa19o51D67yvBfiJ6gQTQ7Kpy6DNfE8C9jidF6WXs/ZHcHOpZ35KNGoxHm0mHS7v7RoREFBI2nH0QQtYtBG/ZSRYqLSbIbPhbBxkSenMLf0uIIfnOXo= 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 1709216941510985.5378983646746; Thu, 29 Feb 2024 06:29:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfhMI-0006IH-U6; Thu, 29 Feb 2024 09:26: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 1rfhM5-0005xl-7U; Thu, 29 Feb 2024 09:25:50 -0500 Received: from mgamail.intel.com ([192.198.163.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfhM3-0005O2-Bl; Thu, 29 Feb 2024 09:25:48 -0500 Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Feb 2024 06:25:45 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa010.fm.intel.com with ESMTP; 29 Feb 2024 06:25:42 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709216747; x=1740752747; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PuIkkbjrFZHQWrlHk+V1lHEGDSQ4p//0zIRr95rqpiw=; b=Jom9ORGqtHWhovYuHhZcYVNgiHMgliYtSCzfPhNGZ5p5k7gpIppGf9uY UjHeV0KG5ji3jX3W1PsJiaOQl6TD6qkhnXupBw1SYX35awB7lAvrEK/Qb XAXw38vSsYk3i8kZMnDDgoYsQ3wEO+losGZdtJTQm9sgzf/DygDASwNXg tkbdig1r9+smyDe1VmqumYZqKNOJPi+zJC4zfXgMJ8cI1VZJZ/3zjpx3v eDSFlLjzM2XMQobDKeuU7Iky6VWq3JE5xY6JVE5HRGK0kltMrfxHKgK3t PhJ2rMimw5/mCTlDwzLXCmYOlloJidCE5vBu4QuMOZ8VvTuLbmGcO/GQP g==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="14322746" X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="14322746" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="7793820" 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" , Paolo Bonzini , Fam Zheng Subject: [PATCH 04/17] hw/scsi/vhost-scsi: Fix missing ERRP_GUARD() for error_prepend() Date: Thu, 29 Feb 2024 22:39:01 +0800 Message-Id: <20240229143914.1977550-5-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240229143914.1977550-1-zhao1.liu@linux.intel.com> References: <20240229143914.1977550-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.11; 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.096, 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: 1709216943255100001 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 vhost_scsi_realize() passes @errp to error_prepend(), and as a VirtioDeviceClass.realize method, its @errp is from DeviceClass.realize so that there is no guarantee that the @errp won't point to @error_fatal. To avoid the issue like [1] said, add missing ERRP_GUARD() at the beginning of this function. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: "Michael S. Tsirkin" Cc: Paolo Bonzini Cc: Fam Zheng Signed-off-by: Zhao Liu --- hw/scsi/vhost-scsi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index 58a00336c2db..ae26bc19a457 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -220,6 +220,7 @@ static int vhost_scsi_set_workers(VHostSCSICommon *vsc,= bool per_virtqueue) =20 static void vhost_scsi_realize(DeviceState *dev, Error **errp) { + ERRP_GUARD(); VirtIOSCSICommon *vs =3D VIRTIO_SCSI_COMMON(dev); VHostSCSICommon *vsc =3D VHOST_SCSI_COMMON(dev); Error *err =3D NULL; --=20 2.34.1 From nobody Tue Nov 26 06:25:32 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=1709216805; cv=none; d=zohomail.com; s=zohoarc; b=Seo2hd9HHkp4OJ/9NOmOob7zXOQ1XcZEfcwjHehPG3A7yo2AFDwprODa9sTsJ/8YVA3n6mXzBpXTSz9xoQ0tSsgI8hHe9/GSmep/THV5rYNc+uOP+CTdT4YICRuC5gWnPkmkTHAFoxSV9lQL/RsQ1rnlPNmQ5/w7iSnZWj9MxEM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709216805; 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=sj86Ofga0BASR1JOosBAsXgN7Rtc6dJt0/MPHYsPiE0=; b=EylhIePCpoiD+kT1Iy1rSen6WjpxHFljuwpgRjXSUTz6PyzTukJmhsB8X/C2BuATXXHq0j7Y2FbAr/OL5rXQBi2F1zK5uParXBPuCXxGCyBSWi+TcuYZKMoHGnlhIwFfwpxLzJNW2cH07eghGFSx7sl1MBoyA/HuSYjMKRfOUFo= 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 1709216805314874.4849441193479; Thu, 29 Feb 2024 06:26:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfhME-0006AC-Vy; Thu, 29 Feb 2024 09:25: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 1rfhM7-00061T-2L; Thu, 29 Feb 2024 09:25:53 -0500 Received: from mgamail.intel.com ([192.198.163.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfhM5-0005Zy-Dt; Thu, 29 Feb 2024 09:25:50 -0500 Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Feb 2024 06:25:48 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa010.fm.intel.com with ESMTP; 29 Feb 2024 06:25:44 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709216749; x=1740752749; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+/cHxbW0WhNo9iRlSuyijZ05ynSZcXySGxgkdVJCUhQ=; b=W+rhM3ppBdfqCw1kYwBKjD06JViUrL8VDCAAhjfxWo3sTMxWU2AfOlqp vM1u9iPR0eDYpAPVZN/N5OuF4hpfs6Yrwg8DTrWkHPqL/3mJl7oUXlbZw ae4N7pQMTVa5VCUh1Odpw51GFko5/0yYCiQVgvBK5rmAXqC9NKtZcFjFR vJp1Cw3f6yHetDSuD3IUhOGky74SiGaSahGbxeBjiNZAPqMD8qSU7oH7Y wUkFu3MlrCXqffByhWOqyAmCg3LjsX0Def++hKXPd4+wLQ0ufKuDQxLf6 l+apQxcHPPu/v6uTgGciNk+Ux5kbIMWRv5iH8yCe7iO9Z+lQUmYclUcLC Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="14322754" X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="14322754" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="7793826" 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 , Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Thomas Huth , Tony Krowiak , Halil Pasic , Jason Herne Subject: [PATCH 05/17] hw/vfio/ap: Fix missing ERRP_GUARD() for error_prepend() Date: Thu, 29 Feb 2024 22:39:02 +0800 Message-Id: <20240229143914.1977550-6-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240229143914.1977550-1-zhao1.liu@linux.intel.com> References: <20240229143914.1977550-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.11; 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.096, 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: 1709216806802100001 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 vfio_ap_realize() passes @errp to error_prepend(), and as a DeviceClass.realize method, its @errp 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: Alex Williamson Cc: "C=C3=A9dric Le Goater" Cc: Thomas Huth Cc: Tony Krowiak Cc: Halil Pasic Cc: Jason Herne Signed-off-by: Zhao Liu --- hw/vfio/ap.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c index e157aa1ff79c..7c4caa593863 100644 --- a/hw/vfio/ap.c +++ b/hw/vfio/ap.c @@ -155,6 +155,7 @@ static void vfio_ap_unregister_irq_notifier(VFIOAPDevic= e *vapdev, =20 static void vfio_ap_realize(DeviceState *dev, Error **errp) { + ERRP_GUARD(); int ret; Error *err =3D NULL; VFIOAPDevice *vapdev =3D VFIO_AP_DEVICE(dev); --=20 2.34.1 From nobody Tue Nov 26 06:25:32 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=1709216818; cv=none; d=zohomail.com; s=zohoarc; b=MKp/acpX9B+aHTBGb/DByvaka7frh6lMVZn3IisFvn6Va44tP41nk7SzaahYL4PZIYoyycxn0S4b32+Gbm5L7IQMQ1SdfJwm4Ephu66dwS15SjXEIPhHsfH2b/zGsHzIakcp/Ygez/Vfh0j163gEreKuTZlyMh2a03O2NAB7fDI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709216818; 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=TJLE7NAhFLHkQT5nmH7cJZuKB7YMXwmpp5TKrMOtn0I=; b=PYcoItHc2PBcZghA15v63bYX1xB9p6v4I1wC+Mp6ZXf/MtdAI3auezl99qRScmAByIyMgcJ7bHQVGj1YcWAITY0Ws8SyzFXh+CcnfBSOJ5YIi+ny+CPr7kYSraY01E9hZC94X/e9MUGfYkoXUmmOaFG8/kS0HRHjrFkVfCpM/ZI= 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 1709216818360339.5503469784062; Thu, 29 Feb 2024 06:26:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfhML-0006Ns-4Q; Thu, 29 Feb 2024 09:26:05 -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 1rfhMA-00064e-5p; Thu, 29 Feb 2024 09:25:54 -0500 Received: from mgamail.intel.com ([192.198.163.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfhM7-0005O2-H0; Thu, 29 Feb 2024 09:25:53 -0500 Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Feb 2024 06:25:50 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa010.fm.intel.com with ESMTP; 29 Feb 2024 06:25:48 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709216751; x=1740752751; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tm2TfL8tCatkLG6f9ax0h2DVCNI++sDtZFIjXdGxA2U=; b=hDBnCndeof+cuNUvpJWLttT0db/Bls1FNs1AzXz2rbabSa1DTIFvJXS0 t4RoAphuki0rZmb3IeW6Hg7fI1OWJXq7ATHcaZiiolyn0/bsAluMzftUC maDzAzXOHzhgPCpW1mjSaba8OguZdSKrbH8MRje+w/zWQV7k7IALNQccI hvTEiT9WekbF9+J64fvKay3V5dg3E320UJtaJ5Wkf7mg33oAOxylv6RuD AhOJXBlmomeA8hcDHp2bVxYFzZl/dSbjTyP6nCeBqZcTwzb4Hc60v2CD1 JEIy8338fR891qVS6Kl4hOUh0XY0FeaXG7PPCuv4vGf3GFXZM4PHapxxP Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="14322767" X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="14322767" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="7793832" 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 , Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH 06/17] hw/vfio/container: Fix missing ERRP_GUARD() for error_prepend() Date: Thu, 29 Feb 2024 22:39:03 +0800 Message-Id: <20240229143914.1977550-7-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240229143914.1977550-1-zhao1.liu@linux.intel.com> References: <20240229143914.1977550-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.11; 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.096, 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: 1709216818890100003 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 vfio_get_group() passes @errp to error_prepend(). Its @errp is from vfio_attach_device(), which @errp parameter 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: Alex Williamson Cc: "C=C3=A9dric Le Goater" Signed-off-by: Zhao Liu Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Thomas Huth --- hw/vfio/container.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/vfio/container.c b/hw/vfio/container.c index bd25b9fbad2e..f66bb01f5b18 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -719,6 +719,7 @@ static void vfio_disconnect_container(VFIOGroup *group) =20 static VFIOGroup *vfio_get_group(int groupid, AddressSpace *as, Error **er= rp) { + ERRP_GUARD(); VFIOGroup *group; char path[32]; struct vfio_group_status status =3D { .argsz =3D sizeof(status) }; --=20 2.34.1 From nobody Tue Nov 26 06:25:32 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=1709216957; cv=none; d=zohomail.com; s=zohoarc; b=H8Rn31Mn6s7EcyT6RIExrHK8OevVh5Z9x9LDl+t+GgndrVwcgx8m5OBmJmbA3uKiqujcdN9SqehsaUPH2MBLAh+PL9Y7pkeBOs0NEVuA3fy6xwSirM+rmB74rCwn4K8He9/AJJ+u6LjCZ7SDlU2gCPmn8s4YK5wHSJsoBcZiVR8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709216957; 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=Urwr0rogPVrys66lTBsaz6/oM17AL/Y2A4HKlLUz0Y4=; b=gqoibU01QuHq4svOUrb2m2DTv4pqEikzURY4Rjvs+jsTwaLGUflks+woYRvcflabRXkImdeLHOJyPWAqC8aIhbgDClrtzoZc0DiVx9lMEWBvizq8/I1DxVlB7GRskja0egiw1WPcR8ZyCLNe9BDnqC4VzLtjLtkfDTtnKcTqevI= 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 1709216957236389.960713209386; Thu, 29 Feb 2024 06:29:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfhMM-0006SR-EK; Thu, 29 Feb 2024 09:26:06 -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 1rfhMC-00069f-Q9; Thu, 29 Feb 2024 09:25:57 -0500 Received: from mgamail.intel.com ([192.198.163.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfhMB-0005Zy-4C; Thu, 29 Feb 2024 09:25:56 -0500 Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Feb 2024 06:25:53 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa010.fm.intel.com with ESMTP; 29 Feb 2024 06:25:50 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709216755; x=1740752755; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tQ5IiIRAKEqm+pxP3vIA++0AE538b0btx11JF7Z59QU=; b=JHUHqXTtXKqYiyJQ3XsgzQjT0n/MNu1hRTIkBBq81eLN6Nfm/4xEDV00 qW60kgUGAZuzSuibuDFzqwVpkYPe6H0oBLiPFdkFKzFwLFMvqPZlTbPxC I+nccMV22oyTtBaQsY6KTBPIdIRChKyRCU5yCQd18pjLHn+HBVwL/GlBK rLnfG6oqCg7SS9TXg9M1TJLW/Kjmf1JLqJLuHHgAyLX4NBXtIcsNUdW+b QNcba6xFkfX72jCtTEhHsU4EVEy2co3WMrZPmyEautbz6lTh8LnaAzFl8 OZSpRIMblarNJZ1hN52VSPYQSa8OE2jpbYIoSqcK3RtAmKdDJvrbT8n7a w==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="14322777" X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="14322777" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="7793838" 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 , Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH 07/17] hw/vfio/helpers: Fix missing ERRP_GUARD() for error_prepend() Date: Thu, 29 Feb 2024 22:39:04 +0800 Message-Id: <20240229143914.1977550-8-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240229143914.1977550-1-zhao1.liu@linux.intel.com> References: <20240229143914.1977550-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.11; 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.096, 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: 1709216959462100003 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/vfio/helpers.c, there're 3 functions passing @errp to error_prepend() without ERRP_GUARD(): - vfio_set_irq_signaling() - vfio_device_get_name() - vfio_device_set_fd() As the widely used helpers, their @errp parameters are so widely sourced that it is necessary to protect them with ERRP_GUARD(). To avoid the issue like [1] said, add missing ERRP_GUARD() at their beginning. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: Alex Williamson Cc: "C=C3=A9dric Le Goater" Signed-off-by: Zhao Liu Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/helpers.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/vfio/helpers.c b/hw/vfio/helpers.c index 678987080228..47b4096c05ee 100644 --- a/hw/vfio/helpers.c +++ b/hw/vfio/helpers.c @@ -110,6 +110,7 @@ static const char *index_to_str(VFIODevice *vbasedev, i= nt index) int vfio_set_irq_signaling(VFIODevice *vbasedev, int index, int subindex, int action, int fd, Error **errp) { + ERRP_GUARD(); struct vfio_irq_set *irq_set; int argsz, ret =3D 0; const char *name; @@ -613,6 +614,7 @@ bool vfio_has_region_cap(VFIODevice *vbasedev, int regi= on, uint16_t cap_type) =20 int vfio_device_get_name(VFIODevice *vbasedev, Error **errp) { + ERRP_GUARD(); struct stat st; =20 if (vbasedev->fd < 0) { @@ -644,6 +646,7 @@ int vfio_device_get_name(VFIODevice *vbasedev, Error **= errp) =20 void vfio_device_set_fd(VFIODevice *vbasedev, const char *str, Error **err= p) { + ERRP_GUARD(); int fd =3D monitor_fd_param(monitor_cur(), str, errp); =20 if (fd < 0) { --=20 2.34.1 From nobody Tue Nov 26 06:25:32 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=1709216817; cv=none; d=zohomail.com; s=zohoarc; b=HogVg0N4uEVX0jVbouhGLng7RtcJlKZ14ftzWUU5Zq86fI3DM3sYL3zUSTyXn9aLT/s6YgpDgv8JfguAXoj0UGtDbVfsImpTX51UG+T/w+w2WWdeIE03Riy/+hqs8s6WKkCmv+Wds3PA9XelJlzhdhHyhvPVzYP2JWb7x3W95GU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709216817; 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=TGWA6DIV2cwFRaPdLMiGT9gNzkO1TzPLX8yujPpkiSs=; b=Rxxd6W4JBVu3Gcwp1zRWVUxSBiTYinlMZHbNZegMfWqj1amYTYKbHg3abml55M2YtMvvlqUyUdLN8xF1i2U7GJ6pOceOfzabeWrSS95mN3mzKYgZIGtYlPWQlOOHa8wlW61XubXDrkx9QQLIX/uZOfbF7Rn0ZAcOkG11U3bLi5U= 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 1709216816996787.8714431654442; Thu, 29 Feb 2024 06:26:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfhMJ-0006Im-7G; Thu, 29 Feb 2024 09:26: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 1rfhMD-0006AL-U2; Thu, 29 Feb 2024 09:25:58 -0500 Received: from mgamail.intel.com ([192.198.163.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfhMC-0005O2-E1; Thu, 29 Feb 2024 09:25:57 -0500 Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Feb 2024 06:25:55 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa010.fm.intel.com with ESMTP; 29 Feb 2024 06:25:53 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709216756; x=1740752756; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IatmqCQ9vAXDypTdX08RatHXOY9Ba/YtMXNoadKHz2M=; b=HOZEM7hN3MK+6WxbW9kBj6fF2PSOnv3dZIv12jfmOzmqKakrVEtTzGnW lIdRKEkg9oYHy8b7+a2K3ltLqgYLV1OmskXZHQM6GsXrb6vuviIEkT5Wd fytwfNhrXoylr70q+knK+BQ3yZP7QYLnoecrrokaF7rrMd6tDgCo/uLdX jNUQmb7VyY+vJ/W5LjLtQHu8ODn92civrBCNIkPE0PVFZlnobOB3UPS0T +sNsq9nK1SDl7r1Rt97tUESvnYjdsD2yb7Y2h7p187GEJm+hhr2WC+F4W D2ypI3BSgEGiTJZemEyej7FNdgigJo1ySIggKGjqkMOloGoETZVcZRBIO g==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="14322786" X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="14322786" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="7793845" 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 , Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH 08/17] hw/vfio/iommufd: Fix missing ERRP_GUARD() for error_prepend() Date: Thu, 29 Feb 2024 22:39:05 +0800 Message-Id: <20240229143914.1977550-9-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240229143914.1977550-1-zhao1.liu@linux.intel.com> References: <20240229143914.1977550-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.11; 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.096, 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: 1709216818890100002 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_cdev_getfd() passes @errp to error_prepend(). Its @errp is from vfio_attach_device(), which @errp parameter 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: Alex Williamson Cc: "C=C3=A9dric Le Goater" Signed-off-by: Zhao Liu Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/iommufd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index 9bfddc136089..7baf49e6ee9e 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -116,6 +116,7 @@ static void iommufd_cdev_unbind_and_disconnect(VFIODevi= ce *vbasedev) =20 static int iommufd_cdev_getfd(const char *sysfs_path, Error **errp) { + ERRP_GUARD(); long int ret =3D -ENOTTY; char *path, *vfio_dev_path =3D NULL, *vfio_path =3D NULL; DIR *dir =3D NULL; --=20 2.34.1 From nobody Tue Nov 26 06:25:32 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=1709216954; cv=none; d=zohomail.com; s=zohoarc; b=OZbC99J4hZYgfVmmbxyI4NRlEk8j6c01Z9ALF6kIW62bZHAs3tOVuaDKO/aF1uR8MLZ9LBkhsYnWvDmS7lYpvwXt3EF/xBFG+TrWtdIi/R/D5GsXp2wnuttUcd0DMcI9uaV+uDF99dGgV78jylnLoX2dSlar0S6RAZIR25zmtFU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709216954; 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=YPUp3t3BX0VbzclR6K1fhYIQlyLWnULDBOHPVYetYhw=; b=SRGI8q5pQYbhheEK5eauKI3DefEeLKhNI4eWkg1mfne4v4wLaJ4TvWmzHk6JwLV7B9v3GIQcyEcwGxyeXjyJi3xo3oVcPrnEzlhW9qorOG2XNnWfF//fhwJ20ewqvXvzLJWbUBio3jzFAsg+1BFKTCvbh4+8ZC2TjUz2inyvtaQ= 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 170921695426977.38998181507009; Thu, 29 Feb 2024 06:29:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfhMM-0006RQ-2U; Thu, 29 Feb 2024 09:26:06 -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 1rfhMI-0006HO-EP; Thu, 29 Feb 2024 09:26:02 -0500 Received: from mgamail.intel.com ([192.198.163.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfhMG-0005c2-PM; Thu, 29 Feb 2024 09:26:02 -0500 Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Feb 2024 06:25:58 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa010.fm.intel.com with ESMTP; 29 Feb 2024 06:25:55 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709216760; x=1740752760; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tLTUDrHSuXuCOuB1SbDv4DvjgsV//tK+czNZPOeaW6Q=; b=nw+JRuXMFb0Vau1TeCDvCSdFNfwlNrMd4v9JRV+psxKFptAOM/QF5cPV 9xwqmsb5h0C2IMW81GEqNJW+yydXPaLtQMbe6t+zTvFQ/I6cxlqumsn69 iIjnzRzUKrmjpljeQnaz9K+S+vjUX+lHmk47POFmeFMNsoalpXqVxpBlU PmFmwSnMvyTRfkR+LwC90vn7ceMGZc1WGD0Imu4WDaut9lI7NTGSsKXpj qVQCzPDiPZD6CLAb9D7+GBIYcg3tb1Y+4xLKdCM4MCrTHQmKf3IbZrdm6 IPTQbONLd2zeUe5/HpK+DtSbL1L/8XJHhe1EQzXZ3I0Hk1mSbfJbkwSRJ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="14322801" X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="14322801" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="7793848" 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 , Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH 09/17] hw/vfio/pci-quirks: Fix missing ERRP_GUARD() for error_prepend() Date: Thu, 29 Feb 2024 22:39:06 +0800 Message-Id: <20240229143914.1977550-10-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240229143914.1977550-1-zhao1.liu@linux.intel.com> References: <20240229143914.1977550-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.11; 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.096, 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: 1709216955266100001 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/vfio/pci-quirks.c, there're 2 functions passing @errp to error_prepend() without ERRP_GUARD(): - vfio_add_nv_gpudirect_cap() - vfio_add_vmd_shadow_cap() Their @errp parameters are so widely sourced that it is necessary to protect them with ERRP_GUARD(). To avoid the issue like [1] said, add missing ERRP_GUARD() at the beginning of this function. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: Alex Williamson Cc: "C=C3=A9dric Le Goater" Signed-off-by: Zhao Liu Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/pci-quirks.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c index 84b1a7b9485c..496fd1ee86bd 100644 --- a/hw/vfio/pci-quirks.c +++ b/hw/vfio/pci-quirks.c @@ -1538,6 +1538,7 @@ static bool is_valid_std_cap_offset(uint8_t pos) =20 static int vfio_add_nv_gpudirect_cap(VFIOPCIDevice *vdev, Error **errp) { + ERRP_GUARD(); PCIDevice *pdev =3D &vdev->pdev; int ret, pos; bool c8_conflict =3D false, d4_conflict =3D false; @@ -1630,6 +1631,7 @@ static int vfio_add_nv_gpudirect_cap(VFIOPCIDevice *v= dev, Error **errp) #define VMD_SHADOW_CAP_LEN 24 static int vfio_add_vmd_shadow_cap(VFIOPCIDevice *vdev, Error **errp) { + ERRP_GUARD(); uint8_t membar_phys[16]; int ret, pos =3D 0xE8; =20 --=20 2.34.1 From nobody Tue Nov 26 06:25:32 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=1709216857; cv=none; d=zohomail.com; s=zohoarc; b=kAZ/BjKipUeo6amoPd8+7cEJtfr6tneChCsDjlT02e1dMcE90I08hYzH+h8eA3FeHxwn1o4xxWl3W1nBUqLPurZBce9wWtnbw2RSOMBJHvaGzVzgcXS5ykq6szCwiTkt3JUVyUZwjrWf5ybT2cz+wD2MKhT1TJNh4md8XlB8rc0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709216857; 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=BHMrRYDCz7Cv762++XeEC9rF9Kx+aVj7IK3y6ruZdB4=; b=j0ZCG4bilr6/hS5tOpGJKOd9KpW7Yq57Z4HXVMgrG8sYswqIYViM7pcnyEhtRglIApu73fZ1vSr19I8Oh//N1ZVCFnh//sqPzYZDXDea9QL0sO79YDzv81gU87k8lFSECWvgy1ViDpLaWMioSj8E33oLF5V/kyDIkrNbXmyRcOY= 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 1709216857651143.71599993380426; Thu, 29 Feb 2024 06:27:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfhMO-0006VX-M0; Thu, 29 Feb 2024 09:26:08 -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 1rfhMK-0006Mf-8x; Thu, 29 Feb 2024 09:26:04 -0500 Received: from mgamail.intel.com ([192.198.163.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfhMI-0005cJ-EU; Thu, 29 Feb 2024 09:26:03 -0500 Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Feb 2024 06:26:00 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa010.fm.intel.com with ESMTP; 29 Feb 2024 06:25:58 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709216762; x=1740752762; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pJjZcfjXFxXzVVYX42mhVb27x/DybavYmLqX4bmOvkk=; b=EzJB8fqXnmFnTfGpl2+E7NPGDakZCDAMsURfbIJWTABCvOrw90YnKOLC YB0aM0A2ghKtfwAOHDjCe016IE4Y+HPhq6bQFBs8K4ZL2djp/ANRIY9nV i5OoZrhzh0ZJPceTw1bkiiZdfgqmVebxrL2C84XwmTEK4BK01F32d/4rx CQM18X/FCGpZO0BlV2kWfJmPth6FYuKgFOeixa1oW0JN8C0jailYPQrZ+ xi3wqHacrwdEdZivdGnuIxGeVV+3LpIQKKL5bdyteE6oMDmpN92oWtM3y 6Xd62q/hsj60SicfIrJJuFVj4FMfwYNYWK8sb/cmCMl7BCT8Dw+LDtA3X A==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="14322815" X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="14322815" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="7793855" 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 , Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH 10/17] hw/vfio/pci: Fix missing ERRP_GUARD() for error_prepend() Date: Thu, 29 Feb 2024 22:39:07 +0800 Message-Id: <20240229143914.1977550-11-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240229143914.1977550-1-zhao1.liu@linux.intel.com> References: <20240229143914.1977550-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.11; 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.096, 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: 1709216858918100001 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/vfio/pci.c, there're 2 functions passing @errp to error_prepend() without ERRP_GUARD(): - vfio_add_std_cap() - vfio_realize() The @errp of vfio_add_std_cap() is also from vfio_realize(). And vfio_realize(), as a PCIDeviceClass.realize method, its @errp is from DeviceClass.realize so that there is no guarantee that the @errp won't point to @error_fatal. To avoid the issue like [1] said, add missing ERRP_GUARD() at their beginning. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: Alex Williamson Cc: "C=C3=A9dric Le Goater" Signed-off-by: Zhao Liu Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/pci.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 4fa387f0430d..e70efde11913 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -2136,6 +2136,7 @@ static void vfio_check_af_flr(VFIOPCIDevice *vdev, ui= nt8_t pos) =20 static int vfio_add_std_cap(VFIOPCIDevice *vdev, uint8_t pos, Error **errp) { + ERRP_GUARD(); PCIDevice *pdev =3D &vdev->pdev; uint8_t cap_id, next, size; int ret; @@ -2942,6 +2943,7 @@ static void vfio_unregister_req_notifier(VFIOPCIDevic= e *vdev) =20 static void vfio_realize(PCIDevice *pdev, Error **errp) { + ERRP_GUARD(); VFIOPCIDevice *vdev =3D VFIO_PCI(pdev); VFIODevice *vbasedev =3D &vdev->vbasedev; char *tmp, *subsys; --=20 2.34.1 From nobody Tue Nov 26 06:25:32 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=1709216844; cv=none; d=zohomail.com; s=zohoarc; b=Nj++7dLYEeuJrLjRSV1RKECCSIPeb1mX7wOsj27BBYYvgWRJSzOkdx4PtIOSMAA1yJa+RfbdfggeBOJbFjcyzPjN38thg5IUNz3NSGHNF+YooCFtJjjlnd7CfGwwIdtZE7YMijTuYjTMaMqjgdh35B8V1U2Oq7y+oiNcNwjvTw4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709216844; 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=j2ZfS2J9EmvVE7uBF6fdjfCNwsQq5O44dRgbD659/vA=; b=K7+FXf3MWD9sMbwkWwW+E1jqfmPKS0Uz4yTzwiycdWAi0wODk9wDyiEz98LxzaDhWIDoosVKi5YRsuHzhStDiFwZJiNzVu9oVDWPXNv7V8a/Vrk+bgjl6w1nhy3UTiHIrzv/uOM0niHBOVkOWzMGc5G1OGtWP2oGjFmoYSni/5Y= 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 170921684438283.49315161029597; Thu, 29 Feb 2024 06:27:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfhMP-0006W8-At; Thu, 29 Feb 2024 09:26:09 -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 1rfhMM-0006TO-QC; Thu, 29 Feb 2024 09:26:06 -0500 Received: from mgamail.intel.com ([192.198.163.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfhML-0005c2-1R; Thu, 29 Feb 2024 09:26:06 -0500 Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Feb 2024 06:26:02 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa010.fm.intel.com with ESMTP; 29 Feb 2024 06:26:00 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709216765; x=1740752765; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kNODUsMzllw9MObKDaUkVo9ZpXJ/rC/x12S70m6gtbA=; b=BqTTSnQw5HX86aSX+pHqghaK2hQM8B6Dm6oMLqOLPwtVwOI8r0bxB/Oo VGSyB9nmaA0mEZW6Zv9bJbIiK4+8Gs6EO6/r1vIQSpw/YGi2bGCgk5RDp ftuzw0x5UmbnjA/d8qk/NaXbUG6lzScLU4gyHkVY79oyt6idkQTQNn8sw AwLVk+NfFZ3ofFKZCCNrd4TsXMHKqiWDbsKknoprpXQgzMVpyLlypfXyL pXbWyGyff2P9Nv8J+8T7Fm7MANijVwErSvLyHYyNCqirAom/ZZ7q5d2Y7 DZlBnIvIb5I3eeQvNbnKaCRx7aY3prd69XkQ96PWnP+J/ODmsEw6+2p7a Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="14322821" X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="14322821" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="7793865" 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 , Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH 11/17] hw/vfio/platform: Fix missing ERRP_GUARD() for error_prepend() Date: Thu, 29 Feb 2024 22:39:08 +0800 Message-Id: <20240229143914.1977550-12-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240229143914.1977550-1-zhao1.liu@linux.intel.com> References: <20240229143914.1977550-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.11; 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.096, 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: 1709216844929100001 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 vfio_platform_realize() passes @errp to error_prepend(), and as a DeviceClass.realize method, its @errp 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: Alex Williamson Cc: "C=C3=A9dric Le Goater" Signed-off-by: Zhao Liu Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/platform.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c index a8d9b7da633e..dcd2365fb353 100644 --- a/hw/vfio/platform.c +++ b/hw/vfio/platform.c @@ -576,6 +576,7 @@ static int vfio_base_device_init(VFIODevice *vbasedev, = Error **errp) */ static void vfio_platform_realize(DeviceState *dev, Error **errp) { + ERRP_GUARD(); VFIOPlatformDevice *vdev =3D VFIO_PLATFORM_DEVICE(dev); SysBusDevice *sbdev =3D SYS_BUS_DEVICE(dev); VFIODevice *vbasedev =3D &vdev->vbasedev; --=20 2.34.1 From nobody Tue Nov 26 06:25:32 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=1709216861; cv=none; d=zohomail.com; s=zohoarc; b=SZOlM//pH6gkIdonQcdWmiKYnGz1BNQHLU3EhcCFuYXBlf4AzNostdENdmHHvx+JxzLkFl4Ty1VKOSA9vGdCvVwjtfRWtBhwjGFCYEVwRbBjDR3yywfNjbgRWDtSSX8x4zh5nqX5Z6e86rG77S28B0iEBhsJROddRbMRUoa2DEA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709216861; 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=IF5ylnm3wgZKpBpWihYH99MNtDIxBxYg8jYi+3QgV1k=; b=EHWtQ2yr03u24JUtb22J3LkOjEBY7yTgDg7eKJDwNgZ/YbdvxcIQ0nNNHz9AITkYpD5+MAS04+2GgWI/yvLkXZdRuZJp2T1mlrJ6zFQciGQvdaBPPdQhjCwQ6QBadz2xergiK6Ku8RbM9ZYpavJ9HJ2YYfEXlFJJqWfzKTbz/To= 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 1709216861293488.32264557039; Thu, 29 Feb 2024 06:27:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfhMn-00079w-FX; Thu, 29 Feb 2024 09:26:34 -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 1rfhMj-00074I-KJ; Thu, 29 Feb 2024 09:26:29 -0500 Received: from mgamail.intel.com ([192.198.163.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfhMh-0005cJ-UT; Thu, 29 Feb 2024 09:26:29 -0500 Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Feb 2024 06:26:05 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa010.fm.intel.com with ESMTP; 29 Feb 2024 06:26:03 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709216788; x=1740752788; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IGkhbFpn/c+13m0fNpAXvTFF2XOHAXW1Bu+Nbsc9m2M=; b=m5pYWLhquiamzvuBrHCUVqN5e/wPEwPtzXSCHxLaZhieQBjVl06KIYsO CffrXrnqOMAnsbzh2BK9NC8ksAmxQrkh6PAaD5rJ4qCtQZriOGT1Iqz1U iSc5guqX4PZSN5v2j1DAIc8TnT6FqSs/eYSH5KRvKUqepkLGZMcsp0gKj GEOWSyxNW4oX1HQRT9w89uEut0SV37igrLuZ92FIGfyA1ICWUeN7dTnSg mmsnTJvSkN3jmIsu9jRuszet9AtC4YfksPSnvk9sMYnoQTPJgVkyxM5F8 JuaMnabjmXPieAImxD+cQmgV8XbYYZE6wRt/sVfPVlQpkqGEnv4aRkvd+ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="14322828" X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="14322828" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="7793872" 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" Subject: [PATCH 12/17] hw/virtio/vhost-vsock: Fix missing ERRP_GUARD() for error_prepend() Date: Thu, 29 Feb 2024 22:39:09 +0800 Message-Id: <20240229143914.1977550-13-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240229143914.1977550-1-zhao1.liu@linux.intel.com> References: <20240229143914.1977550-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.11; 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.096, 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: 1709216863186100004 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 vhost_vsock_device_realize() passes @errp to error_prepend(), and as a VirtioDeviceClass.realize method, its @errp is from DeviceClass.realize so that there is no guarantee that the @errp won't point to @error_fatal. To avoid the issue like [1] said, add missing ERRP_GUARD() at the beginning of this function. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: "Michael S. Tsirkin" Signed-off-by: Zhao Liu --- hw/virtio/vhost-vsock.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c index d5ca0b5a1055..3d4a5a97f484 100644 --- a/hw/virtio/vhost-vsock.c +++ b/hw/virtio/vhost-vsock.c @@ -121,6 +121,7 @@ static const VMStateDescription vmstate_virtio_vhost_vs= ock =3D { =20 static void vhost_vsock_device_realize(DeviceState *dev, Error **errp) { + ERRP_GUARD(); VHostVSockCommon *vvc =3D VHOST_VSOCK_COMMON(dev); VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VHostVSock *vsock =3D VHOST_VSOCK(dev); --=20 2.34.1 From nobody Tue Nov 26 06:25:32 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=1709216941; cv=none; d=zohomail.com; s=zohoarc; b=CQODMLXLxQEitLv/EyaY/Y2edLcQjMeP2Eg2j538FxtefV3YFNQHEYEtk4Jb1WYcSTaR7Jtk3n9jCmqFCpYClwYeIKPOtUMh2g+JNCiZBdSomJJ8/GlqyAMVf0F57ZNQumR6SuCAO0Wl5cRXgWZNsl+GY1SeMIROyNZQt2vDOfA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709216941; 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=GqC01Mj61OeY6Supgdf4WSraG1x+8xWOGUX2XbzdfH4=; b=b1utewv0Ca1XXFBkKoRdmTpGJ5v4KSFcledKy7+4bfbaS1CgurUw0QzzBkPaAKyEHdEpTVUidOI8zXoSaoxoMhBJXX5W5lp+gb32PSmQ5Iz/EtKGkiYIXXkwz/s+Wz/GqLU1XiC943O1ol1dur45Biid/xXiHPlpDMg8JR+qodk= 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 170921694150545.61064101323541; Thu, 29 Feb 2024 06:29:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfhMt-0007S7-L6; Thu, 29 Feb 2024 09:26:39 -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 1rfhMk-00075j-Kn; Thu, 29 Feb 2024 09:26:31 -0500 Received: from mgamail.intel.com ([192.198.163.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfhMi-0005c2-R1; Thu, 29 Feb 2024 09:26:30 -0500 Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Feb 2024 06:26:07 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa010.fm.intel.com with ESMTP; 29 Feb 2024 06:26:05 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709216789; x=1740752789; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xzkP10xeaHsq8UV5Wca3B+v53CNbpWYjrVZWa4XoviU=; b=XMPQ0Gd7N6G9WZXsIGsADM3FZUUyE5Otp2looK5fWcbWY8JDYOWNdXeL WWcZFj6gyhQLAjRBe+aIMhKrMVNPs2LoalijBMs8Pw/plUf55K5sSp+9h hEMBvvulXcqwlK42baDNn3Gdk5UsVfLEEMY/u+kR165vbkAA5UJ1Dg9n9 0909KAi6NYcE/95TMSZzAMHUDuVENZWWiuNkA5cDrwFw+UeDVb+BE/E9a q40SzVt50q4YPEEgcMTG9xwh8t/npgS3wzFtErdmBBJe2rsuphA25W7KP 5pNXeIsTtTeMj548Kq/jfjpyJpT8VsLTij6m01Od7o0ru4iU//wV+Qwhy Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="14322833" X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="14322833" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="7793885" 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" Subject: [PATCH 13/17] hw/virtio/vhost: Fix missing ERRP_GUARD() for error_prepend() Date: Thu, 29 Feb 2024 22:39:10 +0800 Message-Id: <20240229143914.1977550-14-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240229143914.1977550-1-zhao1.liu@linux.intel.com> References: <20240229143914.1977550-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.11; 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.096, 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: 1709216943256100002 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/virtio/vhost.c, there're 2 functions passing @errp to error_prepend() without ERRP_GUARD(): - vhost_save_backend_state() - vhost_load_backend_state() Their @errp both points to callers' @local_err. However, as the APIs defined in include/hw/virtio/vhost.h, it is necessary to protect their @errp with ERRP_GUARD(). To follow the requirement of @errp, add missing ERRP_GUARD() at their beginning. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: "Michael S. Tsirkin" Signed-off-by: Zhao Liu --- hw/virtio/vhost.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 2c9ac794680e..2e4e040db87a 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -2199,6 +2199,7 @@ int vhost_check_device_state(struct vhost_dev *dev, E= rror **errp) =20 int vhost_save_backend_state(struct vhost_dev *dev, QEMUFile *f, Error **e= rrp) { + ERRP_GUARD(); /* Maximum chunk size in which to transfer the state */ const size_t chunk_size =3D 1 * 1024 * 1024; g_autofree void *transfer_buf =3D NULL; @@ -2291,6 +2292,7 @@ fail: =20 int vhost_load_backend_state(struct vhost_dev *dev, QEMUFile *f, Error **e= rrp) { + ERRP_GUARD(); size_t transfer_buf_size =3D 0; g_autofree void *transfer_buf =3D NULL; g_autoptr(GError) g_err =3D NULL; --=20 2.34.1 From nobody Tue Nov 26 06:25:32 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=1709216868; cv=none; d=zohomail.com; s=zohoarc; b=SpdMDnVAQg2lJGOTJPEwq4l7/quH1S+XZ+TxixCaZp6FzncGDFq8Qn4d6m3f8vgJ1X+otGeS114iDO11igO4cfBSEo5jRKzKSTEPTFYnU6ds7y/iC9a5QnhddbXHrUV3HMnhj0EQT1eihH5N2Sh3E+a7/qpjl62vWgsqGapaxK8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709216868; 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=UzJKT3nzPtgLXmtQfgdh3jtw1ZEI6Mn32FuRqTGuidY=; b=Xgyzkm6VqMtmp0/0kBunEIa4RW/DF7W+JR/Pp87NR8vWeMBCn/+QnqUSPXjjbsk3ABCBOHTjH9RuXSJ9xpYYOdZvWsVKciM2gKbSZ6lSj5jATcqV1wMfSz7xIsSUxbqVF70K0MXdUlWOPY3CzqOYYD4XFZltOQs5XST8/wn4Pio= 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 1709216868093824.1688965432788; Thu, 29 Feb 2024 06: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 1rfhMt-0007SJ-NW; Thu, 29 Feb 2024 09:26:39 -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 1rfhMn-0007BW-Js; Thu, 29 Feb 2024 09:26:33 -0500 Received: from mgamail.intel.com ([192.198.163.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfhMl-0005ee-Tu; Thu, 29 Feb 2024 09:26:33 -0500 Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Feb 2024 06:26:09 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa010.fm.intel.com with ESMTP; 29 Feb 2024 06:26:07 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709216792; x=1740752792; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wPeEnKkJYPPIgo94FX+zh/eKLbECzV39wf2hQuNxEqw=; b=jpwVpbAV5bZaCj4da+FFeaPmQgZz5e1KI9dvt3TK/6ZgJTo22HwZdLQl JOfHBPcFbpQooyKNL68r+6VwcPnLNbKpf4G8GgOGSbNL4frhra075zZI5 +bdurFoH1afpsB9471kqyvCsoaUeM9rE1hj/WAr/benfv03i+AlY5WCNM zNTX1jFc1IjbvYqlwQsZED6dGxDoObVH7Ws8bVrGNl2Fi8b3WvdtzDD8R f6K5nkZEEIptjjB3qIDxiVAx5VhIwOTVS2Jv34b5TFcEW1SCzjESlXVpn wWgjCLf1qutpz2gGyRit9zP5be9eHff4+qD5U2o3n6LyTo6AWaHFeFQsP g==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="14322841" X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="14322841" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="7793892" 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 , Peter Xu , Fabiano Rosas Subject: [PATCH 14/17] migration/option: Fix missing ERRP_GUARD() for error_prepend() Date: Thu, 29 Feb 2024 22:39:11 +0800 Message-Id: <20240229143914.1977550-15-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240229143914.1977550-1-zhao1.liu@linux.intel.com> References: <20240229143914.1977550-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.11; 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.096, 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: 1709216869043100001 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 migrate_params_check() passes @errp to error_prepend() without ERRP_GUARD(), and it could be called from migration_object_init(), where the passed @errp points to @error_fatal. Therefore, the error message echoed in error_prepend() will be lost because of the above issue. To fix this, add missing ERRP_GUARD() at the beginning of this function. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: Peter Xu Cc: Fabiano Rosas Signed-off-by: Zhao Liu Acked-by: Peter Xu Reviewed-by: Fabiano Rosas --- migration/options.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/migration/options.c b/migration/options.c index 3e3e0b93b439..b98cd639979e 100644 --- a/migration/options.c +++ b/migration/options.c @@ -1057,6 +1057,8 @@ void migrate_params_init(MigrationParameters *params) */ bool migrate_params_check(MigrationParameters *params, Error **errp) { + ERRP_GUARD(); + if (params->has_compress_level && (params->compress_level > 9)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "compress_level", --=20 2.34.1 From nobody Tue Nov 26 06:25:32 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=1709216843; cv=none; d=zohomail.com; s=zohoarc; b=izLBoz2KbEEIBVVOyc6kvFFd1mskX2BBRMEia2OmkhCJW09mtB4HP7WL6Q+738L8XaSkruci9CppTNCrY1i7c+69Ht40myUVU2UeCcjyYw2hbd8sBB2biaS9zfuX8A8zOM1cr3IVwVXkUweE2APaQ84hH8jEE/E4xVJ9y9hrkL8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709216843; 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=suf4h1kdXYRBHstI+kFDRd0ilcWl7wc/CZxI3MNm4V8=; b=kAMr4Phjw0vscNjYVfhqNbbxRHtnqWDUG/52f5hMOa9M0ls5FWPV9bCYBAAq8vm9FIVqacPiJUBnVve+FxFdDZGV+vDnzOE7kFoaJK7zuaLizw6SZZdE3t3lYJAKoB5p3JeRkWZLZnNWHV2aWY6TovCK5kUSsTjmUAry9kUG5jQ= 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 1709216843299864.4321104265363; Thu, 29 Feb 2024 06:27:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfhMq-0007Fp-GO; Thu, 29 Feb 2024 09:26:37 -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 1rfhMl-000798-QH; Thu, 29 Feb 2024 09:26:33 -0500 Received: from mgamail.intel.com ([192.198.163.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfhMk-0005cJ-7x; Thu, 29 Feb 2024 09:26:31 -0500 Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Feb 2024 06:26:12 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa010.fm.intel.com with ESMTP; 29 Feb 2024 06:26:10 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709216790; x=1740752790; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wARfCODNefZRcg7ugBVxhGmYWq5sTblq3roBF65heH0=; b=ZENqIgkJQxHP08lDcmxfN28cK44925pj5n/lAcB6MaZ0Rcb59KkECaB1 dfRRL48vmw/3EliiWibGdM/xbKtuCUbZuPW33cxZnSdkHU+ROoOQOPqnC qpJAZPDEgiuozDTFJpyawIojve6bTBJ3In2i7lj1pcp+7VP/6k7WNKdLA toQW/HN5DP5OCs/S7jsAPuO9Ct79MsxWx1OhYHGjiPM/lb81RHO/rzof6 L1rIXsAFjfDGXXtF4CAWTT7CemKo66kT4D3k8QZojUgKerj5+gKRk/IyI XPE/rsfKRLhMZZu+lfehXh0mNFB8Qf92IuYdT5wi2GKGr+57fZ6179KDB Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="14322863" X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="14322863" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="7793903" 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 , Jason Wang Subject: [PATCH 15/17] net/vhost-vdpa: Fix missing ERRP_GUARD() for error_prepend() Date: Thu, 29 Feb 2024 22:39:12 +0800 Message-Id: <20240229143914.1977550-16-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240229143914.1977550-1-zhao1.liu@linux.intel.com> References: <20240229143914.1977550-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.11; 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.096, 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: 1709216844931100003 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 net_init_vhost_vdpa() passes @errp to error_prepend(), and as a member of net_client_init_fun[], it's called in net_client_init1() and gets @errp from this caller. But because netdev_init_modern() passes &error_fatal to net_client_init1(), then @errp parameter of net_init_vhost_vdpa() would point to @error_fatal. This causes the error message in error_prepend() to be lost because of the above issue. To fix this, add missing ERRP_GUARD() at the beginning of this function. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: Jason Wang Signed-off-by: Zhao Liu Reviewed-by: Thomas Huth --- net/vhost-vdpa.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 3726ee5d6763..6c1fa396aae1 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -1751,6 +1751,7 @@ static int vhost_vdpa_get_max_queue_pairs(int fd, uin= t64_t features, int net_init_vhost_vdpa(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp) { + ERRP_GUARD(); const NetdevVhostVDPAOptions *opts; uint64_t features; int vdpa_device_fd; --=20 2.34.1 From nobody Tue Nov 26 06:25:32 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=1709216868; cv=none; d=zohomail.com; s=zohoarc; b=TTTDe1Lml9Qu2J8wRLB2fTCBsKfMLFqOHWUVr/77SuYgHVGCK9s1u8clFzvG6pJDOcLiuBekvh+O0wwTUAQfc9N/svpORmQT4gQ0tTiDymOvrEthan3cG2aO964psrAhDs4VhywCTeFvkJ4L4CZ23VhHM+nkSrpLv5t/cUI6lWE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709216868; 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=pty2MS/afLU5pKXyXetdanxJYO2uqCTD4+Yoxv0Nqg8=; b=alcq2Vo5DM4R4FqTndpH0pR/yjRK69LPDn8DMcc/Rg8YPxm9UAvaPRt+t+G52nmDu9ejRTHvcrTM+E6/1SCUYWMmyGabYGy8leTwRxvn4YeSXuNIR53WmAGwk2d5mZFuU8MqE2L3be5mkdxihRAHQIJ78I+TLVJ0NI5gHTimG/c= 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 1709216868799881.4996967672748; Thu, 29 Feb 2024 06: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 1rfhMv-0007dB-SZ; Thu, 29 Feb 2024 09:26:41 -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 1rfhMn-0007Cc-VK; Thu, 29 Feb 2024 09:26:34 -0500 Received: from mgamail.intel.com ([192.198.163.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfhMl-0005c2-8g; Thu, 29 Feb 2024 09:26:33 -0500 Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Feb 2024 06:26:14 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa010.fm.intel.com with ESMTP; 29 Feb 2024 06:26:12 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709216791; x=1740752791; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1uR8nwqYf2xyCLjXffYB8T2F9oXrqWJ3oP/O8Q6/HKo=; b=gMlMKNaXg4BLiZoh70WoMxC/M5uPve3plIjsEXCHECmWzereL0uFHAt5 jHZ4DuxpZyJK2EGAbp2I3gC70SKACjZ9qEy94cBsbz5Yp5EN23syGp72+ qYVmwAR8q/EVvXAIjtE0gvwT5ZAr+5e1w9uyjGT5+1nIYjokfmbcnU20f LSpQjdAmV4Qf7lJYP78RiPo+hOHkIpL0zrdMIIOu5qEjQ/0g9TRpeSbOA q00dmChj/PmvzfpEz+XZr4BPHi8NaXtdOZtSRrpcfi35YC31hCyAfozW1 /CjqDBhFhxQ7thePciKHuC+wzm45v0y7+CkxGdsskk/tcYtslGi2j6woY Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="14322890" X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="14322890" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="7793917" 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 , Marcelo Tosatti Subject: [PATCH 16/17] target/i386/sev: Fix missing ERRP_GUARD() for error_prepend() Date: Thu, 29 Feb 2024 22:39:13 +0800 Message-Id: <20240229143914.1977550-17-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240229143914.1977550-1-zhao1.liu@linux.intel.com> References: <20240229143914.1977550-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.11; 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.096, 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: 1709216871012100007 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 sev_inject_launch_secret() passes @errp to error_prepend(), and as an APIs defined in target/i386/sev.h, it is necessary to protect its @errp with ERRP_GUARD(). To avoid the issue like [1] said, add missing ERRP_GUARD() at the beginning of this function. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: Paolo Bonzini Cc: Marcelo Tosatti Signed-off-by: Zhao Liu Reviewed-by: Thomas Huth --- target/i386/sev.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/i386/sev.c b/target/i386/sev.c index 173de91afe7d..72930ff0dcc5 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -1044,6 +1044,7 @@ sev_encrypt_flash(uint8_t *ptr, uint64_t len, Error *= *errp) int sev_inject_launch_secret(const char *packet_hdr, const char *secret, uint64_t gpa, Error **errp) { + ERRP_GUARD(); struct kvm_sev_launch_secret input; g_autofree guchar *data =3D NULL, *hdr =3D NULL; int error, ret =3D 1; --=20 2.34.1 From nobody Tue Nov 26 06:25:32 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=1709216844; cv=none; d=zohomail.com; s=zohoarc; b=iORmIjEc+mb0/Q3/qF2RtanpuvbMlPqRbiGZgkWd4pB84e//9Vqv4hM3XFUoa27Gc4KyLUCiy778HjQbrR9uPEvXivbjsPElwKXEhD5EjwUOvoV6BYpZ0q7g2TAPM5bI5UlwIPzks/ndo34jD7HZyYRPiWcbXiZDFeT+l7WfPaw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709216844; 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=iJJgD7aQH28qiOsIsMCDwQD6b4+iqaM4jinNd+u7LJo=; b=Q2Yv6j6C+aHzP1YESQwHo7ylS9hZzR6X5HNed5zMRpjykinpkOapVa6DyAEuGfAQ9/elqgW2tAebmeLQhJ3+nOSwfIiP2pBV9Huqxv8BdL1FEVJSJPDtZ5OesV6WW+FOLwVMbK50RXDLpLnmLI7oDSTJtc9MtSAHOJzcgmntDks= 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 1709216844137243.91267152176385; Thu, 29 Feb 2024 06:27:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfhNC-0000wM-TF; Thu, 29 Feb 2024 09:26: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 1rfhN8-0000h7-DZ; Thu, 29 Feb 2024 09:26:54 -0500 Received: from mgamail.intel.com ([192.198.163.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfhN6-0005cJ-Ef; Thu, 29 Feb 2024 09:26:54 -0500 Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Feb 2024 06:26:17 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa010.fm.intel.com with ESMTP; 29 Feb 2024 06:26:14 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709216812; x=1740752812; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fTQuhRaqLeTABBmdIxDPpGa8BFdB31dG2lR3Ap7rPTI=; b=NrwO6wAaC1BK0jxZ9BcY1banj1NSgWDSpxRYLpxF1O1u616SEciM11V3 iB0HXcBYPX7A6fS1t4alEpEBGZrZBKIQtkLLw5Ai1gloJ/qWtt9xNJ4F3 4OxOLESSmz1D2+M/KdKIcl1O3NWemnt9IreRLYxTdj7dyPkgYclFmWlFN iQxFbtfzc38sQAPMF7MV4zNL4hb0TzwgjNBEmx/4ZIU+Jvh80aCH96Cfd TBfPBbf9X8Mmiclj5qJEmRrNhHS50gUv9vqUy7E6P8SDLFg5Ef0xXWoxh 0RGlKwCxuV6Y0CM335QaoQ4Qdx4zUxRFSunvwottQ+cUYB/YhSEbz6/vW Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="14322895" X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="14322895" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="7793929" 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 , David Hildenbrand , Richard Henderson , Ilya Leoshkevich , Thomas Huth Subject: [PATCH 17/17] target/s390x/cpu_models: Fix missing ERRP_GUARD() for error_prepend() Date: Thu, 29 Feb 2024 22:39:14 +0800 Message-Id: <20240229143914.1977550-18-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240229143914.1977550-1-zhao1.liu@linux.intel.com> References: <20240229143914.1977550-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.11; 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.096, 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: 1709216844929100002 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 target/s390x/cpu_models.c, there're 2 functions passing @errp to error_prepend() without ERRP_GUARD(): - check_compatibility() - s390_realize_cpu_model() Though both their @errp parameters point to their callers' local @err virables and don't cause the issue as [1] said, to follow the requirement of @errp, also add missing ERRP_GUARD() at their beginning. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: David Hildenbrand Cc: Richard Henderson Cc: Ilya Leoshkevich Cc: Thomas Huth Signed-off-by: Zhao Liu --- target/s390x/cpu_models.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index a63d990e4e8e..1a1c09612271 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -503,6 +503,7 @@ static void error_prepend_missing_feat(const char *name= , void *opaque) static void check_compatibility(const S390CPUModel *max_model, const S390CPUModel *model, Error **errp) { + ERRP_GUARD(); S390FeatBitmap missing; =20 if (model->def->gen > max_model->def->gen) { @@ -566,6 +567,7 @@ S390CPUModel *get_max_cpu_model(Error **errp) =20 void s390_realize_cpu_model(CPUState *cs, Error **errp) { + ERRP_GUARD(); Error *err =3D NULL; S390CPUClass *xcc =3D S390_CPU_GET_CLASS(cs); S390CPU *cpu =3D S390_CPU(cs); --=20 2.34.1