From nobody Tue Feb 10 12:57:44 2026 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=1708677859; cv=none; d=zohomail.com; s=zohoarc; b=g3BaEpzxxkZSq+LJibr0KKeL+DpwFM5rYzj8j+Cf312B7g/vilMIfdNAdLlOA/dKM2I6bEP7hQT37V5BeCi6Y8dzbDfq9r/BzCPmF3No76CXakEvyL5/n50VV7NIvXT9DrqcVZQHnbnERk251Dg1/NrLciNMhCY6OD9Bq+lln/Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708677859; 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=1YNSjsjEdYRwkJtJvO7Pa+gTfATl+wQ1290TPC4JqB0=; b=Tyb4yzl6TgiJ90GlAHbp00CTRgWkGdYJXwpgEaPJ7Ou7IlWMZ0NWH33m+5CF9TUUj7XdTgBlN/y6dDZimrAW9YBwvlgmpzrLpRS9L/h3cqlF0NZtnFzH9SSlx2qh9nR6hg+aL8H8e9G5EqHr6GeBDU5acr2gI5dxBcXqtlHod5g= 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 17086778594419.92558861156499; Fri, 23 Feb 2024 00:44:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdR9k-0003M6-Db; Fri, 23 Feb 2024 03:43:44 -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 1rdR9i-0003K6-K5; Fri, 23 Feb 2024 03:43:42 -0500 Received: from mgamail.intel.com ([192.198.163.7]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rdR9g-00006f-VD; Fri, 23 Feb 2024 03:43:42 -0500 Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Feb 2024 00:43:39 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa007.fm.intel.com with ESMTP; 23 Feb 2024 00:43:35 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708677821; x=1740213821; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7QWx7fmzjgK24CK+pej4cEHInJmThr5dADvX24YS+7Q=; b=SRjkvBZ1KSXYHA/6xy45UcNOt96PUwxErF6URpeys7x8Ie4hKsCcsP+c ar40p/o9YQPPddQ/G6QIT1xgYUJsh2sAmewIOfEqE4rzLGPtIQBChu0e1 jadgASs2gp5skH+iMh3FvzTZDs9lG2VWN5w6NE3y5gz7k72anzvikNtYw 1e7Fx34tCxUhCA3pId6GoItqtZL5/Zj8u3efNbrRPmZxxXFACIRASpnMw /EDSur5NUu8bVp32lsUEf/Ft2T91J1hZ3KoDLpBefKOEurdQwuGnIzJHJ rOf4uKpiPVn37GzW0K0e/CLcFoF/H148nJZqGNP3iKj/0xymPEvvCDz84 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10992"; a="28413855" X-IronPort-AV: E=Sophos;i="6.06,179,1705392000"; d="scan'208";a="28413855" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,179,1705392000"; d="scan'208";a="5731812" From: Zhao Liu To: Jonathan Cameron , Fan Ni , Laurent Vivier , Alistair Francis , "Edgar E . Iglesias" , Peter Maydell , "Michael S . Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Markus Armbruster , Paolo Bonzini , Michael Tokarev Cc: qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-trivial@nongnu.org, Zhao Liu Subject: [PATCH v2 4/7] hw/misc/xlnx-versal-trng: Check returned bool in trng_prop_fault_event_set() Date: Fri, 23 Feb 2024 16:56:50 +0800 Message-Id: <20240223085653.1255438-5-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240223085653.1255438-1-zhao1.liu@linux.intel.com> References: <20240223085653.1255438-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=192.198.163.7; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.002, 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: 1708677861719100003 Content-Type: text/plain; charset="utf-8" From: Zhao Liu As the comment in qapi/error, dereferencing @errp requires ERRP_GUARD(): * =3D Why, when and how to use ERRP_GUARD() =3D * * Without ERRP_GUARD(), use of the @errp parameter is restricted: * - It must not be dereferenced, because it may be null. ... * 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. * * Using it when it's not needed is safe, but please avoid cluttering * the source with useless code. But in trng_prop_fault_event_set, @errp is dereferenced without ERRP_GUARD(): visit_type_uint32(v, name, events, errp); if (*errp) { return; } Currently, since trng_prop_fault_event_set() doesn't get the NULL @errp parameter as a "set" method of object property, it hasn't triggered the bug that dereferencing the NULL @errp. And since visit_type_uint32() returns bool, check the returned bool directly instead of dereferencing @errp, then we needn't the add missing ERRP_GUARD(). Suggested-by: Markus Armbruster Signed-off-by: Zhao Liu Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- Suggested by credit: Markus: Referred his explanation about ERRP_GUARD(). --- v2: * Add the @errp dereference code in commit message to make review easier. (Markus) * Check the returned bool instead of dereferencing @errp. (Markus) --- hw/misc/xlnx-versal-trng.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/misc/xlnx-versal-trng.c b/hw/misc/xlnx-versal-trng.c index b8111b8b6626..6495188dc748 100644 --- a/hw/misc/xlnx-versal-trng.c +++ b/hw/misc/xlnx-versal-trng.c @@ -644,8 +644,7 @@ static void trng_prop_fault_event_set(Object *obj, Visi= tor *v, Property *prop =3D opaque; uint32_t *events =3D object_field_prop_ptr(obj, prop); =20 - visit_type_uint32(v, name, events, errp); - if (*errp) { + if (!visit_type_uint32(v, name, events, errp)) { return; } =20 --=20 2.34.1