From patchwork Tue Mar 12 08:22:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 779691 Delivered-To: patch@linaro.org Received: by 2002:a5d:604e:0:b0:33e:7753:30bd with SMTP id j14csp1907563wrt; Tue, 12 Mar 2024 01:26:06 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXOo/SPUHon5Lda7LXjNdt8EoOUg54jR3mtkbXpQPLTVCtnUomWzZ/fjhgey9BUpuxuHkYYkPbziNN5TjmDgddD X-Google-Smtp-Source: AGHT+IHw/y0XHtzgrBBCqpww7pVBKXFrOBc3xN9cYy28YxG1AZBuxl6P5hgJS8Mnz4ecyzcP3Vxd X-Received: by 2002:a05:622a:19a4:b0:42f:2998:4eea with SMTP id u36-20020a05622a19a400b0042f29984eeamr12742438qtc.21.1710231966359; Tue, 12 Mar 2024 01:26:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710231966; cv=none; d=google.com; s=arc-20160816; b=h7Rp7v8WNN4LKNWXt972W/sgAhBWU2oBWEHtGcvHlmdkGEo5DHWPKqSBHaY9rBcWZY Tu6VlZw/W61HMfUQ3jsblW6GmH47lL75qzg6dmN9cQ/4eucgyrR+h0CLl0NScv6tRoCU WBh8OpaZYnpbuqAxK8nudtIWlGHk0Jmx9fQQFHiFpdpX5l35hUF46u3fP7KuieAZO4hZ trlnWDD9q4jtoA+oBWgaaou5ficef9fy6wLtwAtukK4WTH2nDB1S4cv4rPysTK094/Tz aWt53ZcQ54uqRg5a0x3MUV9jTT75GZvzZAHGzLxv2ENa/IQM2l2UzPMUaOIfhTlW4QIn ABhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=29XjHGwit3vYXMB9dG4vvP3w+ZRgmYEAu29xmgeR40E=; fh=HY5pWZMkKdGYi5ykDWiurjSG5ijDNBoz1USnl5iXY5k=; b=z7PwLXvP3EMWCyhybm79MXf1WSJmqODrLNBxr6uLgf/G+HtoGNZw9EA7Kvnt557ynt HyEvM0csw2Aub3cpXyfJ/ivo8tMKGRS6pA+Wa7iSeIasL1NUGRvgh/rifIzNL7yB2rpF pj9T9iPzGaL+KmTvBMb/tUzhF033Kii2HYI3BuxM4noYw85dFlKvShU+CPp3y+dIrDEL zznkbPUX/oOkgzWaIYR9wjEaHYPRnzjP/k1dRU56lwbNOVbx/BaCYKKWZHEK49JKLQ3O GkP8/75drtXBcTzDaXgcLpzOUvhZb1/yilcyw96qaYU0OwIGKHpM69G0ZrIZC00WQZnZ TlYA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="AX4t/Vah"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id r1-20020a05622a034100b0042e7e274203si7083115qtw.21.2024.03.12.01.26.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2024 01:26:06 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="AX4t/Vah"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjxQ1-0005sn-Hb; Tue, 12 Mar 2024 04:23:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjxPy-0005rj-He for qemu-devel@nongnu.org; Tue, 12 Mar 2024 04:23:26 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rjxPv-0001BM-RZ for qemu-devel@nongnu.org; Tue, 12 Mar 2024 04:23:26 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-4131b1f8c91so25236155e9.3 for ; Tue, 12 Mar 2024 01:23:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710231801; x=1710836601; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=29XjHGwit3vYXMB9dG4vvP3w+ZRgmYEAu29xmgeR40E=; b=AX4t/VahYZcM87BIA5LZ0LFDZ899y3UkP1QNKUqZRGY1b0s10GoKAdJXtJMeJY7KHz 7drWnOAcSx1IthKJR2u9JZ+UCE4gIqgiD2E4jza07NjkiTqD5KMQpUyOn70tlJhotcwf /jWuvbra6vCETc3LeA9Szgc9yIYqWelcQ/gL9gCNCpoCpP6hfJiL2VRQRVj2oVqzRpMu GTQtjuQoF5aedpn7+ip3Zi9TSNYHoCRW+YFUp3+j3f2CkiGFy+dR0YYg9ASxLjaHvHOH gdDgOvC7vZj+Gkb75n2UwgoyTclB7wqU2XSUIzKqnVASViZzlhbFImVMWXLtYFBDTgW+ Uw+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710231801; x=1710836601; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=29XjHGwit3vYXMB9dG4vvP3w+ZRgmYEAu29xmgeR40E=; b=noD13LpemdhPA/IQhQmRPHwNf4OJMn9E6lIczPnCO+NDfmnIxQ931ZL4GyAcTGLsuf 9K9UEQ4kqFRbCJdfI+X9IL85HXEgMYN58lndvCm8xEDvdclmhP7INnT0wMmRdx01HK7Q MJHGr+GVYsydtEyJoKVITveQNsiiga2rAxB9/F83wLqbJeqRtQp5rjrGNzA9oHJg4vPN ChOY6dTE7Y8Nup7XWjsDSQua5B7JoJ4w2zv29/5hb3g675I1MqrOK5W7/qdXkY9mLy+g WTtnmNp1Sdi62zxKsnGTsFSLkM1oupReX3d5a4NxljRAC3jyyG+sdP8uMsa6X/q8XaJI ngBg== X-Gm-Message-State: AOJu0Yw6JA1oaBrm568HHtUtqjNfhSxFNjXgrB1Qo8y9pK343r2XeJwj FfUZIZawavEyi79r6EWTPldLpxEXR0TMpP5rNN7zEjn03pCWK+h5Vv7pwjseVIz5A0tNNAWDXQE b X-Received: by 2002:a05:600c:5190:b0:413:27d0:44ff with SMTP id fa16-20020a05600c519000b0041327d044ffmr4080264wmb.8.1710231801005; Tue, 12 Mar 2024 01:23:21 -0700 (PDT) Received: from m1x-phil.lan ([176.187.206.139]) by smtp.gmail.com with ESMTPSA id a7-20020a05600c348700b0041330d49604sm2480108wmq.45.2024.03.12.01.23.19 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 12 Mar 2024 01:23:20 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, qemu-arm@nongnu.org, qemu-block@nongnu.org, Zhao Liu , Juan Quintela , Manos Pitsidianakis , Michael Galaxy , Steve Sistare , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PULL 06/13] hw/misc/ivshmem: Fix missing ERRP_GUARD() for error_prepend() Date: Tue, 12 Mar 2024 09:22:31 +0100 Message-ID: <20240312082239.69696-7-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240312082239.69696-1-philmd@linaro.org> References: <20240312082239.69696-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=philmd@linaro.org; helo=mail-wm1-x330.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Zhao Liu As the comment in qapi/error, passing @errp to error_prepend() requires ERRP_GUARD(): * = Why, when and how to use ERRP_GUARD() = * * Without ERRP_GUARD(), use of the @errp parameter is restricted: ... * - It should not be passed to error_prepend(), error_vprepend() or * error_append_hint(), because that doesn't work with &error_fatal. * ERRP_GUARD() lifts these restrictions. * * To use ERRP_GUARD(), add it right at the beginning of the function. * @errp can then be used without worrying about the argument being * NULL or &error_fatal. ERRP_GUARD() could avoid the case when @errp is &error_fatal, the user can't see this additional information, because exit() happens in error_setg earlier than information is added [1]. The ivshmem_common_realize() passes @errp to error_prepend(), and as a DeviceClass.realize method, there are too many possible callers to check the impact of this defect; it may or may not be harmless. Thus it is necessary to protect @errp with ERRP_GUARD(). To avoid the issue like [1] said, add missing ERRP_GUARD() at the beginning of this function. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: Juan Quintela Cc: Manos Pitsidianakis Cc: Michael Galaxy Cc: Steve Sistare Signed-off-by: Zhao Liu Message-ID: <20240311033822.3142585-17-zhao1.liu@linux.intel.com> Signed-off-by: Philippe Mathieu-Daudé --- hw/misc/ivshmem.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index a2fd0bc365..de49d1b8a8 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -832,6 +832,7 @@ static void ivshmem_write_config(PCIDevice *pdev, uint32_t address, static void ivshmem_common_realize(PCIDevice *dev, Error **errp) { + ERRP_GUARD(); IVShmemState *s = IVSHMEM_COMMON(dev); Error *err = NULL; uint8_t *pci_conf;