Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3506848rwa; Tue, 23 Aug 2022 06:01:40 -0700 (PDT) X-Google-Smtp-Source: AA6agR7PSOc8g7dxZ9B2DwrAjkOmMvJoCO9xK+WVbjA1DFaFfbRNcRgQC0eha6mvZZMDiJ8qZUVh X-Received: by 2002:a17:90b:3510:b0:1fb:4f93:8141 with SMTP id ls16-20020a17090b351000b001fb4f938141mr3107593pjb.99.1661259699959; Tue, 23 Aug 2022 06:01:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661259699; cv=none; d=google.com; s=arc-20160816; b=V6nsraLOoaz07XmAATpwCXgckhsl0vY7HDsdra9ZkoTZBQuug588v546xiXWmvaUgm 66mL/RyOZNP5XoscKqSEXWM4YaaMx4Xq34R+F1k2Sl7FKvqdWeH4BDSkRZstaRtQ05Or c/b/SfwhH1o8r2N7raOVWqys8UmvlXdX7IeJsJeZxiqFZjv1HRCmmWCsjx8ZsZKTKtCb Sc7EKc1MEq/rH56hc5+IjtfnqUxf7XOFqo+gV36MGVvSaAHRc6vhgdkBBgWozpkVh6Ye M/CC3Z0Hc2T8NnLTMYZJ1+6AK7OcHfAz9P7/o9jbix/r9BR/G1RWRi3liNl3aIkXVnWJ RR9g== 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=7+LHL6TxQx+p0LH5gfSymz9+gvTGR1gLfGR6RNWX6Y4=; b=YzmlZXapIjgsmaRWiX+77XlzQrU+wqyA10rc/7mbNCtwlXMiKn+HyOdVAoQV31CW0Q PBlCeB9da/Pjwr370HMFGz2Z736hqDhEKFR7QlHThSwUVC+CDEr4ltEmzj8+HUpzRV0G HKDa/7jHPgh6kr3sWpblI48nXzYHhF11oaImwKAJjAcee5xih9gubBF9yqmLqUOiNTpL 48dY+ej8/rbz2axkS3uWCkOzpNjbW+M60igmyvjrMKLjqcInKEh+VG9utIWCivumim9X 1JUyAnlf5qVOmhDk7atBeBlzhMyWF9QrlZn/Xv7PAg7So+cMhE4X60gV5fxJjZRCdR0W P9Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rb5qSrtv; 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 q16-20020a63d610000000b00429e7ce5dd8si15124861pgg.567.2022.08.23.06.01.27; Tue, 23 Aug 2022 06:01:39 -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=rb5qSrtv; 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 S1344503AbiHWLdR (ORCPT + 99 others); Tue, 23 Aug 2022 07:33:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358217AbiHWL1d (ORCPT ); Tue, 23 Aug 2022 07:27:33 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67489C2FAB; Tue, 23 Aug 2022 02:25:18 -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 5B410B81C89; Tue, 23 Aug 2022 09:25:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A5996C433D6; Tue, 23 Aug 2022 09:25:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661246716; bh=SiBA1XzLUBHJaB51UOxXGqSYrGpx3sSACQtv/DqHTQE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rb5qSrtvv69+b8fSzhi7D3GYpFVAh2Bffsf+Z99+WYO+oqx0+gYadWd5Rr9lgiT+1 nfM1ZBj0VwyUxgfs3LMfaMbjlCIxsg8hxKtKH+b0cugrexKdgj83Lwa3qo9G2Dm1RN JbiUwZD3dde4ABLOfUSMj/INxjC3qlc588MV7KCw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe JAILLET , Sasha Levin Subject: [PATCH 5.4 166/389] misc: rtsx: Fix an error handling path in rtsx_pci_probe() Date: Tue, 23 Aug 2022 10:24:04 +0200 Message-Id: <20220823080122.562955186@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080115.331990024@linuxfoundation.org> References: <20220823080115.331990024@linuxfoundation.org> User-Agent: quilt/0.67 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: Christophe JAILLET [ Upstream commit 44fd1917314e9d4f53dd95dd65df1c152f503d3a ] If an error occurs after a successful idr_alloc() call, the corresponding resource must be released with idr_remove() as already done in the .remove function. Update the error handling path to add the missing idr_remove() call. Fixes: ada8a8a13b13 ("mfd: Add realtek pcie card reader driver") Signed-off-by: Christophe JAILLET Link: https://lore.kernel.org/r/e8dc41716cbf52fb37a12e70d8972848e69df6d6.1655271216.git.christophe.jaillet@wanadoo.fr Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/misc/cardreader/rtsx_pcr.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/misc/cardreader/rtsx_pcr.c b/drivers/misc/cardreader/rtsx_pcr.c index 4c707d8dc3eb..5807aefd4c88 100644 --- a/drivers/misc/cardreader/rtsx_pcr.c +++ b/drivers/misc/cardreader/rtsx_pcr.c @@ -1485,7 +1485,7 @@ static int rtsx_pci_probe(struct pci_dev *pcidev, pcr->remap_addr = ioremap_nocache(base, len); if (!pcr->remap_addr) { ret = -ENOMEM; - goto free_handle; + goto free_idr; } pcr->rtsx_resv_buf = dma_alloc_coherent(&(pcidev->dev), @@ -1547,6 +1547,10 @@ static int rtsx_pci_probe(struct pci_dev *pcidev, pcr->rtsx_resv_buf, pcr->rtsx_resv_buf_addr); unmap: iounmap(pcr->remap_addr); +free_idr: + spin_lock(&rtsx_pci_lock); + idr_remove(&rtsx_pci_idr, pcr->id); + spin_unlock(&rtsx_pci_lock); free_handle: kfree(handle); free_pcr: -- 2.35.1