Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp658488pxb; Tue, 5 Apr 2022 17:37:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdWUdrR2eC1867LyTEhEO4q1n4d0q7EgoMJAXL8D3ihmwFJHEPYuns5yQiQtolwjBg270u X-Received: by 2002:a05:6402:2219:b0:418:ed4e:f999 with SMTP id cq25-20020a056402221900b00418ed4ef999mr6149695edb.121.1649205334977; Tue, 05 Apr 2022 17:35:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649205334; cv=none; d=google.com; s=arc-20160816; b=yQT5ar6ZG1yXrvnWDmFFRRn5ODR8fON0JWbkG7nW6DiKhsxPwz6YSNamZf/ZKEjwxj fyNtHb4g0awG5e01R4yhgXsm4QMat1n52kdoDCbTh8tiB09Thb55QFyt4SoArxpy3pel +C8LxBaiqTTXeEflXo+vYX3/uu8yL5xiAnwwsZ9QQlDOjjqeGM31bT2O/JgIseRv6XHL 2e+4/s7gHYMv4i+NyveW5BJiZqjU3KWq2Y82d9Spr+q0yq/bdPDcW/p1NRim/dUX3SSz lCYkVdLPSIGqAuQF1BaUlCZjvJlSjehl+T04SsLSRP2jCDTY3TO6lfjzmSrHsq0/6pRB cSpw== 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=sF5iD2S3y1cJPO5+6ZkgLIJAFaWvC2l1F+VZZBVMGPY=; b=wNVs2U3bPQUmHatIJTvYDPo2tub7uFBWYmrGq9IZIoMyQmnbfW4GithCdm3V/Y7S2F uvQQNB18GM1rtZ9Y/TRkg0DmE+4DzAApQJkCx71RFfprAn5pKUDW3kCNibolnWc0QYuZ 92zZdC7Du2I7LHuIEfgIGQApBuHbtHZmXHLKwjauFDuULjrBigyTNHvDQmPp8mwNvHKD UCC1z7PWHLkQwB3msc7tEsijQCdFcOFLQW4qZxDuzK9yl6yvvalOZ6qsrcuNeBpeyfIY 63usTNrfLCp3waoJ0w3V5UTAjdgmOrwrVK70UAFXie5nR5DUzbSPRPCEcaxRSBFwpU7Y 00JQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=V9YmgRW+; 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 kx7-20020a170907774700b006df7df025b6si10667322ejc.19.2022.04.05.17.35.09; Tue, 05 Apr 2022 17:35:34 -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=V9YmgRW+; 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 S1344335AbiDENFH (ORCPT + 99 others); Tue, 5 Apr 2022 09:05:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238839AbiDEJQR (ORCPT ); Tue, 5 Apr 2022 05:16:17 -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 C4061CF4B7; Tue, 5 Apr 2022 02:01: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 74BD8B818F3; Tue, 5 Apr 2022 09:01:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8B04C385A1; Tue, 5 Apr 2022 09:01:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649149300; bh=KoGQ+0vWP49KzgTOCU/ifdDn7F7KOjvEzSHR2vQTS+U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V9YmgRW+s6inMPeYwYHPM8NXcObQ5fTD5dQB4e6r9rC/kVFcpYGEOHEUCKdANRpGH bZJZ1k54PzktQ7ENUYqZDDYAxYCOSNSyzqfSp7VPwpzoVxKE8u6BPlTGf1bHlCEmJe z3N1sy+houiSxOXA96qWTkETeS7COzEWbUoGjclE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Qing Wang , Andy Shevchenko , Sasha Levin Subject: [PATCH 5.16 0665/1017] serial: 8250_mid: Balance reference count for PCI DMA device Date: Tue, 5 Apr 2022 09:26:18 +0200 Message-Id: <20220405070414.021776769@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=-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 67ec6dd0b257bd81b4e9fcac89b29da72f6265e5 ] The pci_get_slot() increases its reference count, the caller must decrement the reference count by calling pci_dev_put(). Fixes: 90b9aacf912a ("serial: 8250_pci: add Intel Tangier support") Fixes: f549e94effa1 ("serial: 8250_pci: add Intel Penwell ports") Reported-by: Qing Wang Signed-off-by: Andy Shevchenko Depends-on: d9eda9bab237 ("serial: 8250_pci: Intel MID UART support to its own driver") Link: https://lore.kernel.org/r/20220215100920.41984-1-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/serial/8250/8250_mid.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/8250/8250_mid.c b/drivers/tty/serial/8250/8250_mid.c index efa0515139f8..e6c1791609dd 100644 --- a/drivers/tty/serial/8250/8250_mid.c +++ b/drivers/tty/serial/8250/8250_mid.c @@ -73,6 +73,11 @@ static int pnw_setup(struct mid8250 *mid, struct uart_port *p) return 0; } +static void pnw_exit(struct mid8250 *mid) +{ + pci_dev_put(mid->dma_dev); +} + static int tng_handle_irq(struct uart_port *p) { struct mid8250 *mid = p->private_data; @@ -124,6 +129,11 @@ static int tng_setup(struct mid8250 *mid, struct uart_port *p) return 0; } +static void tng_exit(struct mid8250 *mid) +{ + pci_dev_put(mid->dma_dev); +} + static int dnv_handle_irq(struct uart_port *p) { struct mid8250 *mid = p->private_data; @@ -330,9 +340,9 @@ static int mid8250_probe(struct pci_dev *pdev, const struct pci_device_id *id) pci_set_drvdata(pdev, mid); return 0; + err: - if (mid->board->exit) - mid->board->exit(mid); + mid->board->exit(mid); return ret; } @@ -342,8 +352,7 @@ static void mid8250_remove(struct pci_dev *pdev) serial8250_unregister_port(mid->line); - if (mid->board->exit) - mid->board->exit(mid); + mid->board->exit(mid); } static const struct mid8250_board pnw_board = { @@ -351,6 +360,7 @@ static const struct mid8250_board pnw_board = { .freq = 50000000, .base_baud = 115200, .setup = pnw_setup, + .exit = pnw_exit, }; static const struct mid8250_board tng_board = { @@ -358,6 +368,7 @@ static const struct mid8250_board tng_board = { .freq = 38400000, .base_baud = 1843200, .setup = tng_setup, + .exit = tng_exit, }; static const struct mid8250_board dnv_board = { -- 2.34.1