Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3088456rwb; Mon, 15 Aug 2022 17:50:49 -0700 (PDT) X-Google-Smtp-Source: AA6agR5Oe9Y2b2p8kPBqC5hJGZ9q1xZnKt9IlOo8qCCCo7WRoex+JwDGMnzhHlLy2Bo3AO0n0Ziq X-Received: by 2002:a05:6402:d06:b0:440:3e9d:77d with SMTP id eb6-20020a0564020d0600b004403e9d077dmr15846091edb.286.1660611049389; Mon, 15 Aug 2022 17:50:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660611049; cv=none; d=google.com; s=arc-20160816; b=TmEkk+20ZgiFw2+OEK8mTZyO/EcgKCatzkTxfFtQf314Jhs/jD+8tcc84G/1L8w2YE /ymZYURotXmYVL/jcanX3uuBsHCTXRQncvoVQ0dobtV65rohE5PGEEICnIPXuqGcT/3u 8jBBtWzhrn3JvUht3Njc9IU79xRhG1u9OmTPMDx9JEU1RL6TVe2mQ4pvmfIGXyP/hMei vjxt5OqnL/5jysv5p23fCdppnuZlReJIELBlRDknC7t3pKy0gn17QjqSMTJaRn8/1eWW tuzkENI2AP4iBSDvW3CE6XWzg78NTijW+ju30BQjRBUuD1XDRHxy3/RN2zpipsg9SLpy aVVA== 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=mr06dRwAHjN8sacZM5DPAddRvQOxFtkWY/peTkKomKxHfQIw2B/Ged09KYriqfRRj6 eHh+N/kWOyWlY1Zi7xppf13f0vwU0rT0RkDTZ2u3GxBsInz0wJ0pVnyx548GYBxJSRRH lvQXmwtrOtzutvv+iiYPpni3Lx7Ud/ZXmptPwnYBbM447twZ6ZMidxexrPqlYD9CnR7u sLnV5gPuksAJwZ4OP1x9RYzFTgHkTT/+/Zn/OtUqs2GSSQTDIXkSpQtbVa7hcqvXLOp7 NIvjmVpuE9qs0wBqDdLTDEh6WBHus9jsGijxyuOGRx58vuBeh7mFoq0/RZ43WOlzTd+L lUIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="H/cYUHrg"; 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 ne18-20020a1709077b9200b0073086ecd585si9181362ejc.625.2022.08.15.17.50.23; Mon, 15 Aug 2022 17:50:49 -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="H/cYUHrg"; 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 S1350511AbiHPASy (ORCPT + 99 others); Mon, 15 Aug 2022 20:18:54 -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-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