From nobody Fri Sep 5 20:02:07 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5743DC32792 for ; Tue, 23 Aug 2022 11:33:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346630AbiHWLdS (ORCPT ); Tue, 23 Aug 2022 07:33:18 -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-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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.16= 55271216.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/r= tsx_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 =3D ioremap_nocache(base, len); if (!pcr->remap_addr) { ret =3D -ENOMEM; - goto free_handle; + goto free_idr; } =20 pcr->rtsx_resv_buf =3D 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: --=20 2.35.1