Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp689568pxb; Tue, 5 Apr 2022 18:54:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8vP4jnx/2zSdghcMLenIXQioH+3qGk1iL2fnYQ+RVjD+kG8OkJfrYACJovTxn69BmS7Jd X-Received: by 2002:a17:902:740b:b0:156:9eed:d2d4 with SMTP id g11-20020a170902740b00b001569eedd2d4mr6377780pll.80.1649210077374; Tue, 05 Apr 2022 18:54:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649210077; cv=none; d=google.com; s=arc-20160816; b=g1eeiHWaZqrnaldLgi9UIElm9u7GfIraVY9HaZEHjD1VXUKtf8M6Ve5HSYNWm4XuC4 YTJ6iul49L69EUqJ2mlb+EtOrAs0dlHZgU74USRhLavVEFA+syFROjY6dy4xwvPL6ElD Nvs0wMpHfVMMrGDtG1sb2pFzvxnTdj1piwoTxdnjy1XlBCH8Jp/XHmtUC4PwFbEup/IG FURiWj0PfnODR8O8EPTO7q2D6SOiBR7/1AZb0sNI/N7Z6fbgdoKTX9gCMrrzClWTchRY 3gvPBGKzL5mhLT0WsT1o7Ls9vP3+H2TvdWcMNmZ8ztUDDhpnrMOLSCHQR07JTbOJiagY U+vQ== 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=rp4E1rHfEbIatcUf0Z3nsDUv0zO+F7nNhZh7ECTBufI=; b=J2FWZqJxFLP9jNf8oOXlOlbRV1boJck1USMvz/PxQzTLK8DxGXmJR2dLTnvQjuG1H0 Vv36fp/ozXafEXVMfxK2XTiO9glgcPHn1lGcoQQYL4h/ZOzIe6/Z8HvQ+q1S6uRNIqOl FP70P5D+pC4rDRYjTix/LDnMwVowGbSasUpKlR8+xwUgn383tWSKlx0OkcVqnGGvrb9x EaX/9zL0iahX225T5JyB9uHB+OEpXM7MUQ5KVSv7dLMmr6dusOS+XdKUbOOORfBpruBa 4X4SjWVmJYt6Zm/X4LnBHJIzDuPWKa/qi8WDhJ6mw9q8gEvgmlAzEvZXn7dThLJbWw/v x/JQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="mjY/k4bF"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ip9-20020a17090b314900b001bf4e57a5d4si4130280pjb.35.2022.04.05.18.54.18; Tue, 05 Apr 2022 18:54:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="mjY/k4bF"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346158AbiDEPLR (ORCPT + 99 others); Tue, 5 Apr 2022 11:11:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345869AbiDEJoI (ORCPT ); Tue, 5 Apr 2022 05:44:08 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CDD8C6251; Tue, 5 Apr 2022 02:29:42 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 7D434B81CAF; Tue, 5 Apr 2022 09:29:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D106AC385A0; Tue, 5 Apr 2022 09:29:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649150979; bh=xIuKecHdhv3b4YQ0aWDboSEoCQ7kseCY+UT5iwlNlBw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mjY/k4bF1Es6N+T4OJ5Yhz8rBBQJHMNIoqkuuzKjRsWKjqUJETngb4SGqzbQiLq/x ROVY0He7iLtUpGhadRRJ84Y4nwXUY7spdZg5LKACCbweJArROax2mjddl3FsmlbK2F fwTcBhBFf9pVtsMHD/sz50iPkVgqzuPXxq31w8KM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wang Qing , Andy Shevchenko , Mark Brown , Sasha Levin Subject: [PATCH 5.15 213/913] spi: pxa2xx-pci: Balance reference count for PCI DMA device Date: Tue, 5 Apr 2022 09:21:15 +0200 Message-Id: <20220405070346.242428839@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andy Shevchenko [ Upstream commit 609d7ffdc42199a0ec949db057e3b4be6745d6c5 ] The pci_get_slot() increases its reference count, the caller must decrement the reference count by calling pci_dev_put(). Fixes: 743485ea3bee ("spi: pxa2xx-pci: Do a specific setup in a separate function") Fixes: 25014521603f ("spi: pxa2xx-pci: Enable DMA for Intel Merrifield") Reported-by: Wang Qing Signed-off-by: Andy Shevchenko Link: https://lore.kernel.org/r/20220223191637.31147-1-andriy.shevchenko@linux.intel.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/spi/spi-pxa2xx-pci.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-pxa2xx-pci.c b/drivers/spi/spi-pxa2xx-pci.c index 2e134eb4bd2c..6502fda6243e 100644 --- a/drivers/spi/spi-pxa2xx-pci.c +++ b/drivers/spi/spi-pxa2xx-pci.c @@ -76,14 +76,23 @@ static bool lpss_dma_filter(struct dma_chan *chan, void *param) return true; } +static void lpss_dma_put_device(void *dma_dev) +{ + pci_dev_put(dma_dev); +} + static int lpss_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c) { struct pci_dev *dma_dev; + int ret; c->num_chipselect = 1; c->max_clk_rate = 50000000; dma_dev = pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn), 0)); + ret = devm_add_action_or_reset(&dev->dev, lpss_dma_put_device, dma_dev); + if (ret) + return ret; if (c->tx_param) { struct dw_dma_slave *slave = c->tx_param; @@ -107,8 +116,9 @@ static int lpss_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c) static int mrfld_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c) { - struct pci_dev *dma_dev = pci_get_slot(dev->bus, PCI_DEVFN(21, 0)); struct dw_dma_slave *tx, *rx; + struct pci_dev *dma_dev; + int ret; switch (PCI_FUNC(dev->devfn)) { case 0: @@ -133,6 +143,11 @@ static int mrfld_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c) return -ENODEV; } + dma_dev = pci_get_slot(dev->bus, PCI_DEVFN(21, 0)); + ret = devm_add_action_or_reset(&dev->dev, lpss_dma_put_device, dma_dev); + if (ret) + return ret; + tx = c->tx_param; tx->dma_dev = &dma_dev->dev; -- 2.34.1