From patchwork Tue Sep 15 01:22:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jay Fang X-Patchwork-Id: 11775177 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7BA9492C for ; Tue, 15 Sep 2020 01:25:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6246C214F1 for ; Tue, 15 Sep 2020 01:25:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726019AbgIOBZW (ORCPT ); Mon, 14 Sep 2020 21:25:22 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:36090 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725999AbgIOBZW (ORCPT ); Mon, 14 Sep 2020 21:25:22 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 2241AC5E87EC4329AD58; Tue, 15 Sep 2020 09:25:20 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.487.0; Tue, 15 Sep 2020 09:25:10 +0800 From: Jay Fang To: , CC: , , Subject: [PATCH] spi: dw-pci: free previously allocated IRQs if desc->setup() fails Date: Tue, 15 Sep 2020 09:22:49 +0800 Message-ID: <1600132969-53037-1-git-send-email-f.fangjian@huawei.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Free previously allocated IRQs when return an error code of desc->setup() which is not always successful. And simplify the code by adding a goto label. Fixes: 8f5c285f3ef5 ("SPI: designware: pci: Switch over to MSI interrupts") CC: Felipe Balbi Signed-off-by: Jay Fang --- drivers/spi/spi-dw-pci.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/spi/spi-dw-pci.c b/drivers/spi/spi-dw-pci.c index 2ea7380..271839a 100644 --- a/drivers/spi/spi-dw-pci.c +++ b/drivers/spi/spi-dw-pci.c @@ -127,18 +127,16 @@ static int spi_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) if (desc->setup) { ret = desc->setup(dws); if (ret) - return ret; + goto err_free_irq_vectors; } } else { - pci_free_irq_vectors(pdev); - return -ENODEV; + ret = -ENODEV; + goto err_free_irq_vectors; } ret = dw_spi_add_host(&pdev->dev, dws); - if (ret) { - pci_free_irq_vectors(pdev); - return ret; - } + if (ret) + goto err_free_irq_vectors; /* PCI hook and SPI hook use the same drv data */ pci_set_drvdata(pdev, dws); @@ -152,6 +150,10 @@ static int spi_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) pm_runtime_allow(&pdev->dev); return 0; + +err_free_irq_vectors: + pci_free_irq_vectors(pdev); + return ret; } static void spi_pci_remove(struct pci_dev *pdev)