Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp1452875ybb; Fri, 29 Mar 2019 05:00:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqzKFeqZ5IXmKqpYShmSw0wkJSGnfkurmzzdZhGTA4fLsA5P23NB6wR8iCz9RGaQ9ZSvuMyJ X-Received: by 2002:a17:902:8c97:: with SMTP id t23mr936646plo.110.1553860818163; Fri, 29 Mar 2019 05:00:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553860818; cv=none; d=google.com; s=arc-20160816; b=nQ/N72kRVpLxiAfGRYNqLBPOjY80xf6U5Ln3P8LIu7GsMpTXDNMZbVMswy/+bDE0Xe P/0rESOY/8ZjjHF4AAbuqMYq0WEP0y8ZrSlejqq0j8DL7Tcvc6h9WSwHb5c50M8T2SVw pdXY8KP564I1rxmVh26S50Tbdxw9sFVmqy4JgnriEh4eaig7TWNNkeza6FTzOaPYnvJl 2IczNzW+9Lfoc//mdEDPozVCrd1Tn1lvCLuFg/IhdRYcGKKJTw4udEGi2MgJWs5qwmVT A+/ms5MaCCg6sfUnWF2RLHfrLn5+147eiqgZLCL4YQRignZPGHkSkIuF+3aJoJs6yC9u Sn4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-id:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:cc:to:from :dkim-signature; bh=b37RT4uKXDdbkxNeUhAAhSpdbcyTyUQD7FOeyCs8KSw=; b=ENzOJod/Dg8R8xDTVO/bDljtD12LieOKWjo3B/by6KCbAwJ5k5GQI/DpQtII8/UudI 4GPehP3naxYjP1/VvaTIjrHE8GBfBNXHLw2eLQmlhoUU0Qg6WWO2V8rbyY2jFjN9+iJe IaDZ6HPo9QZNwT3InDr9dj/fG0Sqpb9Pf3N2vfezZme2g+TMYHyLLo5aVvwWqENzHZl9 2gzwvjeTszJuZJIaCiM/NPq8givdgN+HjHXvaKNuFZAEXgUG2u/hAowOHZ2Qzv18mIYd IN6TP4AVnoTeVFyfW8fcT8x7ZMBBpa7QOp0hj7hFkqbj0n+XhuTqckVB3T591ag29Iab F5OQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@Synaptics.onmicrosoft.com header.s=selector1-synaptics-com header.b=uqWpgKAf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cv8si1878959plb.326.2019.03.29.05.00.01; Fri, 29 Mar 2019 05:00:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@Synaptics.onmicrosoft.com header.s=selector1-synaptics-com header.b=uqWpgKAf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729517AbfC2L56 (ORCPT + 99 others); Fri, 29 Mar 2019 07:57:58 -0400 Received: from mail-eopbgr790084.outbound.protection.outlook.com ([40.107.79.84]:23352 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729453AbfC2L56 (ORCPT ); Fri, 29 Mar 2019 07:57:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Synaptics.onmicrosoft.com; s=selector1-synaptics-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=b37RT4uKXDdbkxNeUhAAhSpdbcyTyUQD7FOeyCs8KSw=; b=uqWpgKAfCHU3XjcU11CDcG7d9IZMHMS2Eh08QDv/bhdnPxoZt3ye5cUFYVsaYnMhi+CXBMAPhiysuLYqhK6+75NX5PyOrutztOuHRKxg9DpJUcnmE4IWC6H1YOmejtl3+giSOWyxibbZfhp3JnePexY6K+oxuNgnyB3UAfLmoUQ= Received: from BYAPR03MB4773.namprd03.prod.outlook.com (20.179.92.152) by BYAPR03MB4677.namprd03.prod.outlook.com (20.179.91.94) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1730.18; Fri, 29 Mar 2019 11:57:54 +0000 Received: from BYAPR03MB4773.namprd03.prod.outlook.com ([fe80::1a8:1bc4:174b:472b]) by BYAPR03MB4773.namprd03.prod.outlook.com ([fe80::1a8:1bc4:174b:472b%2]) with mapi id 15.20.1750.017; Fri, 29 Mar 2019 11:57:54 +0000 From: Jisheng Zhang To: Jingoo Han , Gustavo Pimentel , Lorenzo Pieralisi , Bjorn Helgaas CC: "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , Robin Murphy Subject: [PATCH v4 3/5] PCI: dwc: Free MSI in the error code path of dw_pcie_host_init() Thread-Topic: [PATCH v4 3/5] PCI: dwc: Free MSI in the error code path of dw_pcie_host_init() Thread-Index: AQHU5iakPXqGrGU6TUeWd4NIoGI2eA== Date: Fri, 29 Mar 2019 11:57:54 +0000 Message-ID: <20190329195014.54e54c45@xhacker.debian> References: <20190329194750.265f6df6@xhacker.debian> In-Reply-To: <20190329194750.265f6df6@xhacker.debian> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [124.74.246.114] x-clientproxiedby: TY2PR01CA0003.jpnprd01.prod.outlook.com (2603:1096:404:a::15) To BYAPR03MB4773.namprd03.prod.outlook.com (2603:10b6:a03:134::24) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Jisheng.Zhang@synaptics.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 60148251-00ad-4915-5425-08d6b43dc6f6 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(5600127)(711020)(4605104)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:BYAPR03MB4677; x-ms-traffictypediagnostic: BYAPR03MB4677: x-microsoft-antispam-prvs: x-forefront-prvs: 0991CAB7B3 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(136003)(366004)(39860400002)(396003)(346002)(376002)(189003)(199004)(110136005)(53936002)(54906003)(478600001)(97736004)(106356001)(446003)(316002)(105586002)(86362001)(102836004)(7736002)(476003)(9686003)(66066001)(305945005)(11346002)(256004)(71200400001)(3846002)(72206003)(71190400001)(8676002)(50226002)(6116002)(4326008)(25786009)(8936002)(2906002)(6512007)(14454004)(486006)(6436002)(1076003)(81166006)(81156014)(186003)(68736007)(52116002)(26005)(76176011)(99286004)(5660300002)(6506007)(6486002)(386003)(39210200001);DIR:OUT;SFP:1101;SCL:1;SRVR:BYAPR03MB4677;H:BYAPR03MB4773.namprd03.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:0; received-spf: None (protection.outlook.com: synaptics.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: XpEU/8iu7x6u9BEOAQxuLy0ANXGqqMmF2KGS/9hlc/aiWj8JCRi3adUUiwxgU9AiOwEJObwsTZxXowHOyTZWCLOASbVvi9A8u3uv2zW1qxI2Xacc+za5DgOk0RCcGSXtR2P40UDg18LhJAAyEWTUtgADTymTRUOkdgE1rnNjiN7YKquePSthJ2qZ7MbLcSgUo2Pjwr4PXPgBFZxYhZfgcaNUfek9f8/D4YJKa/Bg64KbEspxTpOLWebJlUoGNBlGUS1nJDFIOuoDW1iSIgChtnrVEk+76qo5MsHSSdenmgfFvRuIzpe3k4Jicx3GAlqmiMNoeKnmFa4Bna7eFzJ/0gNB8Ckw1/8Hun9AxPbvMOK2oYEmxp+D3DO9Fptj08JUqmb4OrQjw2EijJlwYmF2/l4xN/dfYLam4ZNsFBXBZoA= Content-Type: text/plain; charset="us-ascii" Content-ID: <5CF048EA27826E449B67FB5B91E2B4A7@namprd03.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-Network-Message-Id: 60148251-00ad-4915-5425-08d6b43dc6f6 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Mar 2019 11:57:54.6703 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR03MB4677 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If we ever did some msi related initializations, we need to call dw_pcie_free_msi() in the error code path. We also remove the IS_ENABLED(CONFIG_PCI_MSI) check for MSI init, because pci_msi_enabled() already has a stub for !CONFIG_PCI_MSI. Signed-off-by: Jisheng Zhang Acked-by: Gustavo Pimentel --- drivers/pci/controller/dwc/pcie-designware-host.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pc= i/controller/dwc/pcie-designware-host.c index a71b874ae3c0..acc9be5cf34a 100644 --- a/drivers/pci/controller/dwc/pcie-designware-host.c +++ b/drivers/pci/controller/dwc/pcie-designware-host.c @@ -445,7 +445,7 @@ int dw_pcie_host_init(struct pcie_port *pp) if (ret) pci->num_viewport =3D 2; =20 - if (IS_ENABLED(CONFIG_PCI_MSI) && pci_msi_enabled()) { + if (pci_msi_enabled()) { /* * If a specific SoC driver needs to change the * default number of vectors, it needs to implement @@ -483,7 +483,7 @@ int dw_pcie_host_init(struct pcie_port *pp) if (pp->ops->host_init) { ret =3D pp->ops->host_init(pp); if (ret) - goto error; + goto err_free_msi; } =20 pp->root_bus_nr =3D pp->busn->start; @@ -497,7 +497,7 @@ int dw_pcie_host_init(struct pcie_port *pp) =20 ret =3D pci_scan_root_bus_bridge(bridge); if (ret) - goto error; + goto err_free_msi; =20 bus =3D bridge->bus; =20 @@ -513,6 +513,9 @@ int dw_pcie_host_init(struct pcie_port *pp) pci_bus_add_devices(bus); return 0; =20 +err_free_msi: + if (pci_msi_enabled() && !pp->ops->msi_host_init) + dw_pcie_free_msi(pp); error: pci_free_host_bridge(bridge); return ret; --=20 2.20.1