From patchwork Fri Dec 1 17:15:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 749000 Delivered-To: patch@linaro.org Received: by 2002:adf:f9cb:0:b0:32d:baff:b0ca with SMTP id w11csp411250wrr; Fri, 1 Dec 2023 09:17:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IF/lEnp6RArGoyO7cVjWshQA35YWSISZHvhwffTvxKaqhuLiIM7QurzoWrD2xkepPyOJgax X-Received: by 2002:ac8:5794:0:b0:41e:2d8e:b364 with SMTP id v20-20020ac85794000000b0041e2d8eb364mr33326114qta.53.1701451032136; Fri, 01 Dec 2023 09:17:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701451032; cv=none; d=google.com; s=arc-20160816; b=nHsR/4qpZPUBea7z+hPNwxRHU9Rbm4p41YOK7s57i9I+FrN+nBYChxHcBR8GHXOSOh 8Wziws/mNhdanjDFQPYvgEtKpzFqUgCtrXidj4OuWEgixwzRiJrUjSOf+qtdW2NLQY/U TiRfyMQUHXNSfjfH8RuNebtQtyoehuAg8yAPQ3RM4dP5qNoJpZQUAb5UVdICfkAL1eW3 fWlLkpkQjc5t2pB9Xua+mxmPCmHC1wNbIfOXapMVLjjVzBBU+lgm5qMiZmKKE0o7uLtN dQu6UGP3t9gQVLkYUQNwDJpg8wb9LqI25kurvWIdV3ic1YwLHoV5TDjCJXxFMeEo4VeH FqKg== 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:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=DrKNKLCrqbViEto/bsg54GhvLMk/mxP8+8YpGPYFhyY=; fh=PQIHp3wUb6a2ua+GvEt/8TNPqWDIVeQnMaBje9v4TnE=; b=N1YNanp+BVNoSc8tDjlCB5PhBfSWprjfFrR1sq3WPkkNP5LDUlBtQKKpeTp7PojgAf lJJiHdy4IEueVfRlw8SjmraPUtpWkOa/MV4zgygFVYlq5/UB9U9LJYZLyB04FMD6+u16 GIxiyonWwQFfJD52d0uB/my4QPiR8C/ORZnltHDiD20de3W1qWxUo9mwn7KAGJpHIJad BfUUJLyGfEPT+5VXx6tKnGtWcwuRzhw7zsQMLkpv/4/Lv/gonz9zxXxyVTfgRUOSQY+y kkTBLUgEv8SZ0fPuDEiGHBrmCrrsHVE2Er9DY37dV4KRKUnrfxj5F6xV/uDP6ucmgh6s /GKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZxRz7kih; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bv19-20020a05622a0a1300b00423820be0a9si3824658qtb.350.2023.12.01.09.17.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Dec 2023 09:17:12 -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=@redhat.com header.s=mimecast20190719 header.b=ZxRz7kih; 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=redhat.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r977Q-00034O-Ml; Fri, 01 Dec 2023 12:16:00 -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 1r977A-0002ur-5T for qemu-devel@nongnu.org; Fri, 01 Dec 2023 12:15:47 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r9778-0007lG-2J for qemu-devel@nongnu.org; Fri, 01 Dec 2023 12:15:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701450940; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DrKNKLCrqbViEto/bsg54GhvLMk/mxP8+8YpGPYFhyY=; b=ZxRz7kihGbaYJUiOEbtBaZEhM0FxA0a8dtvmmEX3kfMNe5YYBRKGn/JKRYqNLUrenN+XJ6 MyH74OTzY83w4xWY5KweEXOPdB2fsfOi5Ii++6VJU+f5dq7ywLamgfuuRRGTZywoUdkZgk oBAcOJRugGLRRUNNyU4qNyCckgnRIYg= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-128-eMRTn7UVO-q2sBfkkw9L0Q-1; Fri, 01 Dec 2023 12:15:38 -0500 X-MC-Unique: eMRTn7UVO-q2sBfkkw9L0Q-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-40b443d698eso15703185e9.2 for ; Fri, 01 Dec 2023 09:15:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701450937; x=1702055737; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=DrKNKLCrqbViEto/bsg54GhvLMk/mxP8+8YpGPYFhyY=; b=oKcf6rUSrU4klSYgu1IZavKJs2d8y34p8K5pezLAdmCt4r7xG30dgl4WzAr4lAfasc Gd+n30F1UDV0txBbzr254uiBcbg3MBMtbDkIoGU3V9d4n5R5Sc4HJao5AId74o9Ocv5Z ZyJTGFBfjL9sdvFZU2Hl0IcwxvH39qgpoSqhufp9SFr2XjwG7nPk7nQlWto007/FLT1n O1UbslHNKz3vnZcS91lHAUWyN73m6SWk+dW3ZFIsxIKjId5WPI5dBLFgE6/WAfM1BmYF c/i/vmfblO5OkrHD8aVvAFRTHaDMD8RXYFedXPvh2gFkxfRSDBHESInWvZ2T3tMY7qXq O22g== X-Gm-Message-State: AOJu0YzaPWQSD5i4Uzbz0T58kqdJonMPhZotkY5JjvoOCB6gN6X88R47 aewT218ngpMvh5Q9w/YuwQIfY7F52BKYoCmjuVS3x3HEUUnveLKyRGLcN9LDTcARsrPQu9MYXwA htQiwHG1OASsQPJuPnj7a1UM6Km4FUSVx/pznCh+gQZE0+iQXcQrgDQxAl/CsZoc5ppUF X-Received: by 2002:a5d:4102:0:b0:332:eeba:ee8b with SMTP id l2-20020a5d4102000000b00332eebaee8bmr1154468wrp.24.1701450936833; Fri, 01 Dec 2023 09:15:36 -0800 (PST) X-Received: by 2002:a5d:4102:0:b0:332:eeba:ee8b with SMTP id l2-20020a5d4102000000b00332eebaee8bmr1154452wrp.24.1701450936437; Fri, 01 Dec 2023 09:15:36 -0800 (PST) Received: from redhat.com ([2a06:c701:73e1:6f00:c7ce:b553:4096:d504]) by smtp.gmail.com with ESMTPSA id h7-20020adf9cc7000000b0032d8eecf901sm4750493wre.3.2023.12.01.09.15.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 09:15:35 -0800 (PST) Date: Fri, 1 Dec 2023 12:15:33 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Philippe =?utf-8?q?Mathieu-Dau?= =?utf-8?q?d=C3=A9?= , qemu-stable@nongnu.org, Ani Sinha , Igor Mammedov Subject: [PULL 10/15] hw/acpi/erst: Do not ignore Error* in realize handler Message-ID: <451276c0e247fc8b708105e3b0fdcaf6ed7c13ec.1701450838.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.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.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: 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 --- 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);