Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2869501rwb; Mon, 15 Aug 2022 13:00:25 -0700 (PDT) X-Google-Smtp-Source: AA6agR4Wh8Awy0JgxP7R5Ex0W95l1IGB88JRTowg4slHYH5ojzG1OhPtUC2nAXnXpzaqdhMP7KAq X-Received: by 2002:a17:906:84ef:b0:731:8768:847c with SMTP id zp15-20020a17090684ef00b007318768847cmr11013652ejb.373.1660593625608; Mon, 15 Aug 2022 13:00:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660593625; cv=none; d=google.com; s=arc-20160816; b=rU1+KBMrW0ql7x2s/fb23KH9Z5iGspIw1LR/G4ib3fLzT8oSjxBeBOunWyM9HtHMK0 clpgA5bKZmtRzsCGBhk8jmSJcBs1jox5B896i9cK3hZ16NrHOtbl9UFhaiZfPalSszs/ eX033ylrkpIzKf1WsR8veQgWp9SVQlOpL9OUsqL4lO5H2nGcv+8uZ8/K2A2KjaXfnsXv EBEP3ypVr1sh4FdFBw+m4vIOGkR9luL/Y0DyN011as7urgTAQzjCqCG+Y3UDacxJHpg9 CijoMErWN7VEJrNUnmze6uE9nh5El9i1Kl4YQGbta7GSxRK5WvWpgmMK3TirtD4Ra80+ R7PA== 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=FERLganVbcrnPd6CD0gXhApn7G/+DIe1Yey5uC8WsWk=; b=V8aQZDXQqP1YZVlM9xQcIWSdnbo0CIlOweFxMrG7eZhuYpyuKRlBBdminfdecBKwho 8c3Kiybq3S6MLNmLS4+XVmiHQ/6MA7/Wsj4DwO1Q/b53HnUluo4QmZr2TtwcD/W/KVBi mAZur/aFNqB0ppZcU24DxT2KS+dqkcwl1iaIPEcOcgvNGF1/Uk8XseJp5kXTkwSNP2tx rptW2R/bEiV/bKM2p3Pcl2CkyDcK3Ey2rTjdXiqxxiQgmDxMraUFb0k2FD641vIeHz/j 0zplH4jUjLUuepkzObGdwj7dEobDlsR0XHgYEtoNOxbhxdDWNi6P14/HrBmI5BIg1+xP VP3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FWrSeIKm; 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 hr40-20020a1709073fa800b007386f4ab2a2si1274650ejc.638.2022.08.15.12.59.59; Mon, 15 Aug 2022 13:00:25 -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=FWrSeIKm; 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 S1343744AbiHOTMw (ORCPT + 99 others); Mon, 15 Aug 2022 15:12:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240959AbiHOTI7 (ORCPT ); Mon, 15 Aug 2022 15:08:59 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC18C6443; Mon, 15 Aug 2022 11:35:53 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 88F3961024; Mon, 15 Aug 2022 18:35:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92EDAC433D6; Mon, 15 Aug 2022 18:35:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660588552; bh=BxLSowCUd+gDlvDoIK2xP9edGBiTg8HchpI/r7K7JdA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FWrSeIKm1DRs8AQfMPDZFylEMsohmwA/LY7ySUj/qaHtUNyg4FgeU0IPsSkYEP5bF +7WoxbP56Fqoby85OK740ehx1Ftu1gIVLbMBSNV9jKiZrVK7YGZKs5+8Ddi9d6Zqyl VzvdLHmbTx+TDqTryH0d336pQD7RNqq7Unayl6es= 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.15 441/779] misc: rtsx: Fix an error handling path in rtsx_pci_probe() Date: Mon, 15 Aug 2022 20:01:25 +0200 Message-Id: <20220815180356.115558709@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@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 5121edb0d9ef..62fdbbd55e74 100644 --- a/drivers/misc/cardreader/rtsx_pcr.c +++ b/drivers/misc/cardreader/rtsx_pcr.c @@ -1581,7 +1581,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), @@ -1651,6 +1651,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