Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp637295pxb; Tue, 5 Apr 2022 16:50:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynTrREQkaC/roU70OeRlnSAHRiX99AsbntAvpB0KL6hYjKVJesX36PP7QwBRaonUihG/6R X-Received: by 2002:a17:90b:3851:b0:1c7:80f9:5306 with SMTP id nl17-20020a17090b385100b001c780f95306mr6763794pjb.207.1649202630543; Tue, 05 Apr 2022 16:50:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649202630; cv=none; d=google.com; s=arc-20160816; b=ImVVmpfDxGFLVPV+Ph/m2TWTMxz2FmfhyYBinooELxlSsGR6ad7wRXNciMDbWTH3gY rUAXG99gkBzO75IqVxx/wnyC4xn3bbB216uI78coLgliZC8c0B4NXDZZh9RQMQbduNxB GqlFjX1FeVTTSHrBEVchCAWVcyTYak7DBQ9Ut5u+m52VyhKY7ODlHLQNaNZdrkp7hY18 lOIIW9RaKqxECMg0KUv+vowUlp9x3vhnwJMtp9ubUlcLrqgW+8CSvwk91sNCqpTHwYHv bEGn4CEP1TLmULPi0lSkfKijL7NbdgiOV1c/+x62uyWLVaxhQmSKKCt75YpD9euBQjOb tA7g== 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=gh5DienMShOnBbsArqaNgg9PU/vTo3d9wc6yO8VVKDwUo1fQlFB8U40rA09IGW7bRA K7GOrMS+SvaIR1Aj7PPbjFN5coWOyKlmVPZPr0R6c5g82UsKCMOBqe6WySpyAq8Dp9DO C2B6ZLYpRDp6ICDaNVUrPxFfPrCgIsTJRWTt7AzbfhfREbCmfsNQEno3eTkUxRG187hI aEzAR3xLvMLA1CIcLT+5OySWVnEoDQ5bbnFfV3j/jDbYns81ntnsG0ge7IwFIknWEtK0 X6a8oFqN632ZrD47goq5J/65I4O1paXxbDeAYTwKmCUfPzHjmdoRQkGi0xbhHikayDKm BxUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="iT/EXzgr"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id a8-20020a17090a6d8800b001c72fdc6c3esi3276679pjk.69.2022.04.05.16.50.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 16:50:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="iT/EXzgr"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 853AE126FAB; Tue, 5 Apr 2022 16:34:52 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378991AbiDELj6 (ORCPT + 99 others); Tue, 5 Apr 2022 07:39:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244743AbiDEIwh (ORCPT ); Tue, 5 Apr 2022 04:52:37 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B3311C92A; Tue, 5 Apr 2022 01:43:07 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 9F141614E4; Tue, 5 Apr 2022 08:43:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 112BAC385A0; Tue, 5 Apr 2022 08:43:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649148186; bh=xIuKecHdhv3b4YQ0aWDboSEoCQ7kseCY+UT5iwlNlBw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iT/EXzgrHi7la6/eYfYoa7gJBN9H+gG2aPAl7svSsKqMJSZksudx6K9Qoe6isQfvA rZTojtYhRvOm5vquF+VjQlZsHSeDPyNo8xv70QYvQA+kBjUhkqw1ShHMyYSjPC6eQT KJDXebtY7XBUsEDDbb89HRRyOMgSu7jB4dVifzzs= 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.16 0226/1017] spi: pxa2xx-pci: Balance reference count for PCI DMA device Date: Tue, 5 Apr 2022 09:18:59 +0200 Message-Id: <20220405070400.963127675@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@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=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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