Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp508149pxx; Wed, 28 Oct 2020 09:55:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBBi5lfmKTX/lnnuwnzvKctF4HYjtMbm5WPH9aJTtxGBBoxdiFV8aWJ4I7e61MofUQPj8S X-Received: by 2002:a05:6402:7c8:: with SMTP id u8mr8921814edy.153.1603904119836; Wed, 28 Oct 2020 09:55:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603904119; cv=none; d=google.com; s=arc-20160816; b=o8CXNf0WzdqWSroFyM/6dpQKG1TEWvsLx8zrW2ZZ8oE1GVwBkcSqB0Dt2T3O0jgraE WiW9qDf2cgJBqwHk7oyg++z8H3I9NN96wLRJRoxuv5HjJLt0ZN9sGeWsDGaKJx1Usk3G 0hBY6T5PRit6wxL3HlAVkR4ZKotAkw9BvOJYbwmFIOwbkYqMm2LszZyNALioWr1/1xhP O5BIGPuHjqpEHzD6/V/tiKVk62QlzVqRc0/yJTbE5dCQoP/CEmg7hzbOKintv5yaXPXn m8s4n2bLkBoqPgcVr7MVY9ftqIscNvPfWPwbl7H8ACg98YOB9Gh1axtEy3XuomTOO1Vg HvNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LAGrDX/zINT+AMT5yBRDB2q3WTn5kCe8jrVEAOg0eXU=; b=ncp4JDi5ztQQjtwkCnHUX/XLB5XydJ2eU49jXoPixZEx1eQjtF4gQe1slp5HLKvnk1 6hskv1NnSBWuWSMWwrWLIxXSnuaOE2VXXqId8gGaXYb7tUkEw2oo3UkV8xyDx1BWjK8y k7dYA+Whbb4LFpSXPsbtjnEcExxucOo1A5UXHmqUZskinUX7GLSGkWBODRp6DBDM932I Q7+pjlRUePfWWUlAYGDWZdk1E/QRWu/kJbAvuxWpwgNWCwjLlnNO7v+bMUVOfRyolxLt V3b3wpFO0LQ04kByhJR+caTNrjB825gJaMww6nDO0zu9anFFK6bKjy8UtEePMjA2g7gx DFxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=O3H0SvFE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i5si3856525ejx.656.2020.10.28.09.54.57; Wed, 28 Oct 2020 09:55:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=O3H0SvFE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1818942AbgJ0R0G (ORCPT + 99 others); Tue, 27 Oct 2020 13:26:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:53848 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2441298AbgJ0Ox3 (ORCPT ); Tue, 27 Oct 2020 10:53:29 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E87262071A; Tue, 27 Oct 2020 14:53:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603810408; bh=J4REINZOHT+mo5UJ7vS/fqY36s16U5xGSnBqpbisXW4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O3H0SvFEF6jNz4RrDsTJhpdvNoHArbjkehGL20M22mB5QBAX+87RO6P4pzTZFFsXF 8LtOFMOZlFJtzM9OPS1xRyrFx4eevf6AROjqzJugO2DuGoOIGVRmKUIrSLWMopyt/z ASfUm7FS4FtX/mVmN735UAWy0sP6HHJ6HKxHGiUc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Felipe Balbi , Jay Fang , Mark Brown , Sasha Levin Subject: [PATCH 5.8 128/633] spi: dw-pci: free previously allocated IRQs if desc->setup() fails Date: Tue, 27 Oct 2020 14:47:51 +0100 Message-Id: <20201027135528.697875052@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jay Fang [ Upstream commit 9599f341889c87e56bb944659c32490d05e2532f ] 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 Link: https://lore.kernel.org/r/1600132969-53037-1-git-send-email-f.fangjian@huawei.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- 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 2ea73809ca345..271839a8add0e 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) -- 2.25.1