From nobody Mon Sep 29 22:48:17 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 58D86C00140 for ; Tue, 16 Aug 2022 00:18:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352351AbiHPASz (ORCPT ); Mon, 15 Aug 2022 20:18:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356682AbiHPAMI (ORCPT ); Mon, 15 Aug 2022 20:12:08 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2A1FCCE3E; Mon, 15 Aug 2022 13:29:32 -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 73E26B8119B; Mon, 15 Aug 2022 20:29:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CBCFBC4314A; Mon, 15 Aug 2022 20:29:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660595368; bh=ISFO6hjI4XqtpbbowUxey809oGw5ggq0GNaeJcnkqKU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H/cYUHrgppBSeBRpkAakOXVwCH8vnWBUmR8R+4Lt41jsdJMGNjA7UMrE6LPXo/w8x T3lui1iD5B9n6bFg2HJ8cwUW9VRJ3wQQWHtjtEkvoAE33DYbX/jUvR1Ctxi7aCOtTe 39449NvU2Ro3X2bpIr7LhbL7ydL/N25EpAW4Q7+s= 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.19 0742/1157] misc: rtsx: Fix an error handling path in rtsx_pci_probe() Date: Mon, 15 Aug 2022 20:01:38 +0200 Message-Id: <20220815180509.156224032@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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 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 =3D ioremap(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), @@ -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: --=20 2.35.1