From nobody Fri Dec 19 07:31:06 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16B9AC61D85 for ; Tue, 21 Nov 2023 18:37:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234677AbjKUShY (ORCPT ); Tue, 21 Nov 2023 13:37:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234568AbjKUShM (ORCPT ); Tue, 21 Nov 2023 13:37:12 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B09C5CB for ; Tue, 21 Nov 2023 10:37:05 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA569C433C7; Tue, 21 Nov 2023 18:37:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700591825; bh=3Izh/8YivRbhQV8XlIsV2wimO/ukDV888NfvTAlrLdI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GkqMSfp4QvHraguZpfhrbsvGogT0mgl0KOjBBDILIekYojqExQ9KVG9PhsHPt9H8y DfmLCOjeV9MMba0Ac/3YXGWaxT4T8hRNns2R1y3+5ISLTmmoaNnNP3FkLnX9jJk0kw v6SMoXIjGBsN+wc5Tt+P7mqpmB+3DtewO/ZRr8XIBjkYoq0DHWhXuqZsPuLe6209wp Z3XILl/fzd+z3F/XqqBYyv15lKzS8ioSvjHeOykGj4tupcqw3v2zMKubyUYoPr8bX8 xuDlgq/lCIDo/bn8KaDfhJ8xWlgO7jL+11KQylE/u2yoQnStcYG4YWk1SP2sz1rG9P TCRI4xoxo6ugg== From: Bjorn Helgaas To: linux-pci@vger.kernel.org Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H . Peter Anvin" , "Rafael J . Wysocki" , Dan Williams , Kan Liang , Tony Luck , Giovanni Cabiddu , Yunying Sun , Tomasz Pala , Sebastian Manciulea , linux-kernel@vger.kernel.org, Bjorn Helgaas Subject: [PATCH 8/9] x86/pci: Return pci_mmconfig_add() failure early Date: Tue, 21 Nov 2023 12:36:42 -0600 Message-Id: <20231121183643.249006-9-helgaas@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231121183643.249006-1-helgaas@kernel.org> References: <20231121183643.249006-1-helgaas@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Bjorn Helgaas If pci_mmconfig_alloc() fails, return the failure early so it's obvious that the failure is the exception, and the success is the normal case. No functional change intended. Signed-off-by: Bjorn Helgaas --- arch/x86/pci/mmconfig-shared.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/arch/x86/pci/mmconfig-shared.c b/arch/x86/pci/mmconfig-shared.c index 459e95782bb1..0cc9520666ef 100644 --- a/arch/x86/pci/mmconfig-shared.c +++ b/arch/x86/pci/mmconfig-shared.c @@ -102,14 +102,15 @@ struct pci_mmcfg_region *__init pci_mmconfig_add(int = segment, int start, struct pci_mmcfg_region *new; =20 new =3D pci_mmconfig_alloc(segment, start, end, addr); - if (new) { - mutex_lock(&pci_mmcfg_lock); - list_add_sorted(new); - mutex_unlock(&pci_mmcfg_lock); + if (!new) + return NULL; =20 - pr_info("ECAM %pR (base %#lx) for domain %04x [bus %02x-%02x]\n", - &new->res, (unsigned long)addr, segment, start, end); - } + mutex_lock(&pci_mmcfg_lock); + list_add_sorted(new); + mutex_unlock(&pci_mmcfg_lock); + + pr_info("ECAM %pR (base %#lx) for domain %04x [bus %02x-%02x]\n", + &new->res, (unsigned long)addr, segment, start, end); =20 return new; } --=20 2.34.1