From patchwork Mon Nov 20 13:00:17 2023 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: 745355 Delivered-To: patch@linaro.org Received: by 2002:a5d:5052:0:b0:32d:baff:b0ca with SMTP id h18csp1265528wrt; Mon, 20 Nov 2023 05:01:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IGDtsnwvXZhH7BI7EYu5yC6HMKF+HJilS0EaTEHfVAgETQLJP+dmFzCA2glE2CJvev+ZZiS X-Received: by 2002:a05:6871:2218:b0:1f9:496b:e261 with SMTP id sc24-20020a056871221800b001f9496be261mr1481376oab.15.1700485275437; Mon, 20 Nov 2023 05:01:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700485275; cv=none; d=google.com; s=arc-20160816; b=B95rS3kUf49hoAVftPuZUvjIZV35uKJpOhkiO6DmhIn/tNrvdtegLSX2PtMjOGgJSy Q7n7hnFJ0vHTSXdLpCW/3a23o3v+BA5MrdVgfOCGYbnnAsmub0LbbPEOgrmS2r8n6ZiF Y6ZBJf9hmd86EDGAJkct9u5RWgepkAQomejk9zKQybkJSRGZnrbO+eabZ4HgTpQ9sKsV bVfrG4V3KRHz1Xr6uRieGS7ORpfZwPS9ylTL2j4GK0aCEhkpr+nv90w/M6TjiFg0GnZ6 pAeLEtBYExKno7UX/wiRPt93uL9y3bxt66gizvB+CTiR8CiLcCE3dZrIR2JKTMd25A7T DJTA== 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:message-id:date:subject:cc:to:from:dkim-signature; bh=nUH6aadPR7V8diSKlF1PKzoGVdko20H3FoFOmC9kKJk=; fh=GSOzZ+aUOD5ibYiKZ9VipCBcBs4Ga1/cZrRlKVPKaX4=; b=dv4xK/dpwzkWzlYcdcifp/mY+aMhZ/HeDtxmHFgGMlURfqWgAMiOkgcbgu5IEu7K07 EB+GVBhdiBq1RnIp5WVqTMxmNLmv7uOyKK6FUOXQxbez9d4LBtxQl0orinEo0rJ2QupZ Nn7WoK8cjD01Xz6DSJw+uqNINR5Nz2HhyG8vB9+BW7Nm3Vsq5Dcv+FP9iqNZln/J1xpd MRrmoLyLAWi3Flt6xBtTwthSg9w2iJOCWVppSVKpISgMR7Iagp1s0K+9jsB+wJPRpyMA iCrt9dlphIo0PCstnY+sDLKspppC+9bMNH2XX4/S34I2z1LVgDa7DtwnbA4RtSApv3ks JzNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jQVZcq30; 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 e19-20020ac85dd3000000b0041962d20ecasi7204559qtx.90.2023.11.20.05.01.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Nov 2023 05:01:15 -0800 (PST) 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=jQVZcq30; 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 1r53tE-0000O4-Kp; Mon, 20 Nov 2023 08:00:36 -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 1r53t5-0000Md-NK for qemu-devel@nongnu.org; Mon, 20 Nov 2023 08:00:31 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r53t1-0001Rj-R2 for qemu-devel@nongnu.org; Mon, 20 Nov 2023 08:00:26 -0500 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4083740f92dso15652575e9.3 for ; Mon, 20 Nov 2023 05:00:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700485220; x=1701090020; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=nUH6aadPR7V8diSKlF1PKzoGVdko20H3FoFOmC9kKJk=; b=jQVZcq30gMEh/XSZ902XIFzJzsjG4X83FeJR1AzS7WVHR27rwqZNEe2hJ1t1Pln8Rw 9rCJwamqVikhEAb6VuxivGEHRJndl9yvJYnKRto3nVu30Og81OfJ1yPLnHnIBU31N5/M y+lXnH2amJTXH7TnBKbn5AQ0HCfSGlQZxf4ZaYSH/H+LzTMCfT5Ww5tBnvci5m5+w8/B 4HUIMVKTgQukzeaRkRubuK0Z64sDALNqBMFS4B85nayLZxhHQUpaF4EWzadI2Oup1LZf YPHKJhZzuW47t1F1vWGKGgcsaykDx+8phklFMzC1os9wM5W2zaEnWvrOX4M6u4t899ov OeWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700485220; x=1701090020; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=nUH6aadPR7V8diSKlF1PKzoGVdko20H3FoFOmC9kKJk=; b=NW41brlZHVrsdYEUVIv+QMpcz+PsYpBko6GSFtc8ObVBu1Piw6czGGt50p/V5Nzw71 xkE99HwTYq4bqS+zZaWyVoMErR7496sRyzKkHeEEPbQiBtHKsKbF5tQLuTIWx+AXCuVH LDZwHcaWxKwxlgXQN1ANf8fQqNGFTYG87sZfSEveVty+tZVcfFob8yUkEKbyDHn/FAof skfU5+/T6SwWNzd4ec05SqHbpkiUQbt+SUwudVJhOu8gLbkl89zZDN3uethXkraLDz53 qlF5tmpky59wLXcJz7Tv/ndyBrkBtyQn3PVNXzGWs2UpYFmu8wUAVM3blyiIyjNVn6Ad 5A9Q== X-Gm-Message-State: AOJu0YxejivLmVPkCf8Pr6X+0V4VOH9IT7p/+Q52OARrkPHVsXDCMf5R Z3PLAfjROoTRfzME202pb2Q5fT1OxLL7DpNLoDY= X-Received: by 2002:a05:600c:4f56:b0:3fe:d71a:d84e with SMTP id m22-20020a05600c4f5600b003fed71ad84emr5693257wmq.1.1700485220100; Mon, 20 Nov 2023 05:00:20 -0800 (PST) Received: from m1x-phil.lan ([176.176.181.190]) by smtp.gmail.com with ESMTPSA id r14-20020a05600c35ce00b004094d4292aesm13327370wmq.18.2023.11.20.05.00.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 20 Nov 2023 05:00:19 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eric DeVolder , Markus Armbruster , "Michael S. Tsirkin" , Ani Sinha , Igor Mammedov , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-stable@nongnu.org Subject: [PATCH-for-8.2?] hw/acpi/erst: Do not ignore Error* in realize handler Date: Mon, 20 Nov 2023 14:00:17 +0100 Message-ID: <20231120130017.81286-1-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=philmd@linaro.org; helo=mail-wm1-x332.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 erst_realizefn() calls functions which could update the 'errp' argument, but then ignores it. Use the ERRP_GUARD() macro and check *errp, as suggested in commit ae7c80a7bd ("error: New macro ERRP_GUARD()"). Cc: qemu-stable@nongnu.org Fixes: f7e26ffa59 ("ACPI ERST: support for ACPI ERST feature") Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Ani Sinha Reviewed-by: Markus Armbruster --- hw/acpi/erst.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/acpi/erst.c b/hw/acpi/erst.c index 35007d8017..ba751dc60e 100644 --- a/hw/acpi/erst.c +++ b/hw/acpi/erst.c @@ -947,6 +947,7 @@ static const VMStateDescription erst_vmstate = { static void erst_realizefn(PCIDevice *pci_dev, Error **errp) { + ERRP_GUARD(); ERSTDeviceState *s = ACPIERST(pci_dev); trace_acpi_erst_realizefn_in(); @@ -964,9 +965,15 @@ static void erst_realizefn(PCIDevice *pci_dev, Error **errp) /* HostMemoryBackend size will be multiple of PAGE_SIZE */ s->storage_size = object_property_get_int(OBJECT(s->hostmem), "size", errp); + if (*errp) { + return; + } /* Initialize backend storage and record_count */ check_erst_backend_storage(s, errp); + if (*errp) { + return; + } /* BAR 0: Programming registers */ memory_region_init_io(&s->iomem_mr, OBJECT(pci_dev), &erst_reg_ops, s, @@ -977,6 +984,9 @@ static void erst_realizefn(PCIDevice *pci_dev, Error **errp) memory_region_init_ram(&s->exchange_mr, OBJECT(pci_dev), "erst.exchange", le32_to_cpu(s->header->record_size), errp); + if (*errp) { + return; + } pci_register_bar(pci_dev, 1, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->exchange_mr);