Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3013225rwb; Mon, 15 Aug 2022 16:08:56 -0700 (PDT) X-Google-Smtp-Source: AA6agR6CzGMfKHbiC6Jqm8s6DxLDnNMRj/RvcZ1oLNABzFEpfWNRxy4DTLBgVi1h23EAJKWKbVbb X-Received: by 2002:a05:6402:2b8b:b0:43a:5475:f1ae with SMTP id fj11-20020a0564022b8b00b0043a5475f1aemr16306073edb.363.1660604936684; Mon, 15 Aug 2022 16:08:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660604936; cv=none; d=google.com; s=arc-20160816; b=vzslUFDN267ch/zhI23vaPfLhHw/DYtc199aaG2494lxDScCHY9GGouKAvkBgjkNdM cgfSFRNPIC5kvPCYpVZrrhAJEO2DYU6JswZPpUPxsC3VXXV44VTjCGMVEu0v/lDucw/J Zz8YQHycmmv76mrEyEqEWwLWfWTC5/s/fIu+bkuLeaBxuvHqyXc+ugTfGsskjTkd7YL4 fMCzPqvwTg1YAbQsBmCpUAa0RBSmj+rNmjtiW4F52lhgbAHEcGmAKplBnd0dnuHozdWn 77jyE4Nnz/mDJwqTBggSm1wwN/FqC13I00DRc2lBrHcxNw3Bk/2V4MJyEPIHDfxNjYdt JZ7w== 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=U8lnGD27RKO1VYXGcPe5C987W/VcN/77FwfFN1G4H4w=; b=GKMrhR4V9++Z+w9Q4k8s7ijff56ncv8fzxJvrxE4g3Qm5atKcv0rpWdGV28JWXh08r Zj/UVGbOXCMH2atONbluu7A5HupsqFi29B+08PAmJp9hmVKE0GUTym47UiiqXzBD+9YK DczW0/IY7LBxRw+zk0JkSFvsoeP21rI3QG9oNgM8c0n5yXWat6PfU+Fdvel7wHn3bFpL i7mU7IlVjPeb4Z5VonOnAMnl1oduAMd+VVPjeA/geFgGFEPflkhcfLyPzY1yvTmM2fYT iRyhm9yaDTuyfHhV2p6ra5uI94hJnpVH1QTKVoS5qh+tRo8xRxiTH1uhR2006iXO+1Il 7oeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JpennA+r; 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 g12-20020a056402090c00b0043df7e2a990si10247801edz.264.2022.08.15.16.08.31; Mon, 15 Aug 2022 16:08:56 -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=JpennA+r; 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 S1350360AbiHOVwx (ORCPT + 99 others); Mon, 15 Aug 2022 17:52:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350320AbiHOVrj (ORCPT ); Mon, 15 Aug 2022 17:47:39 -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 C571A60535; Mon, 15 Aug 2022 12:31:56 -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 42D96B81128; Mon, 15 Aug 2022 19:31:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74D9FC4315A; Mon, 15 Aug 2022 19:31:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660591913; bh=ISFO6hjI4XqtpbbowUxey809oGw5ggq0GNaeJcnkqKU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JpennA+rVC23dmt3KSf0eBxhsieabMVmp+ZbjZ4OjF4MNxU6DFvwmxmXhXHcT5iT+ 3TeZ1ToJu6+JtNamSsr/j6syAukVT0/O9B5kspD/0A/jdutxHn78yelf+n1d9ZI+AQ 8CXwOD9bTyosbxfj5Bwm5qEF8VMDRXmidBYXiubM= 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.18 0694/1095] misc: rtsx: Fix an error handling path in rtsx_pci_probe() Date: Mon, 15 Aug 2022 20:01:33 +0200 Message-Id: <20220815180458.085909188@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@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 2a2619e3c72c..f001d99bf366 100644 --- a/drivers/misc/cardreader/rtsx_pcr.c +++ b/drivers/misc/cardreader/rtsx_pcr.c @@ -1507,7 +1507,7 @@ static int rtsx_pci_probe(struct pci_dev *pcidev, pcr->remap_addr = ioremap(base, len); if (!pcr->remap_addr) { ret = -ENOMEM; - goto free_handle; + goto free_idr; } pcr->rtsx_resv_buf = dma_alloc_coherent(&(pcidev->dev), @@ -1570,6 +1570,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