From patchwork Wed Dec 13 13:00:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 753522 Delivered-To: patch@linaro.org Received: by 2002:adf:ff85:0:b0:336:3f68:820c with SMTP id j5csp182353wrr; Wed, 13 Dec 2023 05:05:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IGIW0Igmt8L6b0okDfDrEMiOyNxg5PwV5nIZeHDgluWXE4fPvaEQfc8/lxwKTKgRiZVW9zA X-Received: by 2002:ae9:e311:0:b0:77d:c606:2ea2 with SMTP id v17-20020ae9e311000000b0077dc6062ea2mr9421025qkf.45.1702472754045; Wed, 13 Dec 2023 05:05:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702472754; cv=none; d=google.com; s=arc-20160816; b=VIptGUzmGBZ8jCy1qoRoxCIw02ugAPEA5zLxFYbli6pmKk6L8wpC698d+xQMdDOYp3 gNPZTURTqR8bYHQYbU1u610LAwRwHRRP40wy7dx/KGhzwz3qWWS0l+1E9VMX05Ra+SU+ OOcuWYG95orKYzMkYWW/C2f+Rp0O2Cme4w5d4tcS2fVWfdJIIDS0/1pMeLhjyIVtZvSo dlMlmEGABksP7ToQ9vvks4P8jMl8ifOx4yl61EidlNvbKzJ8RFatyYvTmbx4IOfwjdUP hK4lTGp8JFCFgKwEpKXfxYKpBMZFbD8NK85fR906VcmXkXVCqSu7roVJffljBKd2Oe0Q 8A8Q== 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; bh=QfO6UZq38FuBV0mMZy++WNf0yGn+aYWDoGCpDwjRfEc=; fh=GJzGCCXYftWbcJ02hVUf5c8QKNV7/o9dHGXXBrGmTXE=; b=zKTI+gHU6pV24efsNDuq8/aM0/ENcfdctk/AvxJnwEDxKvKOHg30NmGwB/JWl4TEpV 2UIHPDuETAc4MzwRGwcen/tJUunFmDWnKCB2ylCm4CMheLYE7wygWTjS0EwZ5Bm1e85y cD/lhtYTcYy1jSnIaY7qX425o4k/3IjQIRvqXL0IW5q/3xVE+C4FIWyi2xcFXztLBgHB xMt5P4Wpc+v7x5N5eljN1mOjQnmUNPdhRbxzYL6PiAFWtVRJLTrOl9fSz2RSWbxpcpkX 56nPsfZl96aJfU0aHZNvu/piSNtX7j9SxCreS8xf3JNnLiseIZ/irM76rh9eVuKzpuEu Lg9w== ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d28-20020a05620a137c00b0077dcfd4d7a9si11705595qkl.8.2023.12.13.05.05.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Dec 2023 05:05:54 -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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rDOtg-0001kz-PL; Wed, 13 Dec 2023 08:03: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 1rDOsA-0008LD-MN; Wed, 13 Dec 2023 08:01:59 -0500 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rDOs8-00076O-Pl; Wed, 13 Dec 2023 08:01:58 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id B2C503B445; Wed, 13 Dec 2023 16:01:05 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 564533C8D6; Wed, 13 Dec 2023 16:00:46 +0300 (MSK) Received: (nullmailer pid 1024769 invoked by uid 1000); Wed, 13 Dec 2023 13:00:46 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Ani Sinha , "Michael S . Tsirkin" , Michael Tokarev Subject: [Stable-7.2.8 18/24] hw/acpi/erst: Do not ignore Error* in realize handler Date: Wed, 13 Dec 2023 16:00:27 +0300 Message-Id: <20231213130041.1024630-18-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, SPF_HELO_NONE=0.001, SPF_PASS=-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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé erst_realizefn() passes @errp to functions without checking for failure. If it runs into another failure, it trips error_setv()'s assertion. 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é Message-Id: <20231120130017.81286-1-philmd@linaro.org> Reviewed-by: Ani Sinha Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin (cherry picked from commit 20bc50137f3add52eb4788b420d717de27fed14b) Signed-off-by: Michael Tokarev diff --git a/hw/acpi/erst.c b/hw/acpi/erst.c index aefcc03ad6..2e057b1800 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);