Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3329913rwa; Tue, 23 Aug 2022 03:00:02 -0700 (PDT) X-Google-Smtp-Source: AA6agR5OI4V50MApWpuaIYi5dMhs3SwYoq0l87SdbSRXcsF/ySQWHBwDrkF3NrR/9K9Pf5lVdMzQ X-Received: by 2002:a17:907:2bf8:b0:73d:6cd3:906c with SMTP id gv56-20020a1709072bf800b0073d6cd3906cmr8257829ejc.686.1661248802210; Tue, 23 Aug 2022 03:00:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661248802; cv=none; d=google.com; s=arc-20160816; b=oXyX0ucmzn/MyhlbIGzaX+hCpZHKS4XgUkpNsS6QB6j6SYelGV03sjwX29oN/5+zuj P0cECezmRYDy/jg0Ip9GmpOPAcofMkaj1YLCNPxBMa99vkGQbNTuH4EE50vh/WymVWTP KatJGPNfWYcAJXTMdTRE01y4tXixM4f4GiYpmlioy0bCCaRxVsTQMIwZ4oySlFnWTM7A Ger+P/5zyCQkSKZaREfvFfwgSGOeMr16V88uYStAFR43wo1mY8xH7c+xfB0ikUNNZZg+ iAXI5H1KbF2I3Gx07/ln42WslZ0IScYnv5YcRdshRQWagKuKak0+I+jWfvs/b3UBxHiI 3JAA== 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=N7TqFacehuI5sb5y5j8cuLZxsMHI1UGWp37vBp1CU9U=; b=rq1LexvrIM7JNaxtdQaGUG4J9/zq8VxjGOMewqyYNxhW9fVqAYfCAE9vCHG1X56qbI lKbISbb6d9kCAzaVdUigGS6kXjHCxAIzkh555r00zXFhLmsU9hd0Fqx1yeR8rclg5aSU O2Xf609IitHXla1DaCz0+YWp1klQvoneuyj9+47R/4EOZ4DZsrRbFOZ0jb7qnaQhail0 vXPMy+bJpNBXFR2ZqWiO/IWhXkQ0eTnolROZTsW0W788MgCDO9IMQxbyW2WgsU/L+QaE c7wqreZfa4DJB08Kv3gkgcaFZeJrt1whcz5hYHqxkotYEfXDgt4vtCSm8/39YXFHeQcm CuTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TDuL+OvO; 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 m17-20020a50c191000000b004463b58f287si1573070edf.85.2022.08.23.02.59.36; Tue, 23 Aug 2022 03:00:02 -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=TDuL+OvO; 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 S242876AbiHWJsJ (ORCPT + 99 others); Tue, 23 Aug 2022 05:48:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352128AbiHWJp6 (ORCPT ); Tue, 23 Aug 2022 05:45:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14C6343E71; Tue, 23 Aug 2022 01:43:41 -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 D89466153A; Tue, 23 Aug 2022 08:43:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB05DC433C1; Tue, 23 Aug 2022 08:43:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661244196; bh=nBECbFiTYqDWMZnWshLEHrVJOnspAGOnYPScHv5uORA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TDuL+OvOtzGIkc5IuOXl9p+1TsISBmgxdz75d499W9UerZjssb5Kj3rqZMLLCB/Kw lZ9LdacHZMHu6kWhJdE71oD4Q+F0rz3DYUP2c/ZlVQpwu8wlvgk4QGqQye6GvdN10Z PDEunl9F4x2uUCgyo2NhcJFF49zlh08eIE+7KUpQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe JAILLET , Sasha Levin Subject: [PATCH 4.14 101/229] misc: rtsx: Fix an error handling path in rtsx_pci_probe() Date: Tue, 23 Aug 2022 10:24:22 +0200 Message-Id: <20220823080057.306630618@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080053.202747790@linuxfoundation.org> References: <20220823080053.202747790@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/mfd/rtsx_pcr.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/mfd/rtsx_pcr.c b/drivers/mfd/rtsx_pcr.c index c9e45b6befac..1c7afd9a14e3 100644 --- a/drivers/mfd/rtsx_pcr.c +++ b/drivers/mfd/rtsx_pcr.c @@ -1223,7 +1223,7 @@ static int rtsx_pci_probe(struct pci_dev *pcidev, pcr->remap_addr = ioremap_nocache(base, len); if (!pcr->remap_addr) { ret = -ENOMEM; - goto free_handle; + goto free_idr; } pcr->rtsx_resv_buf = dma_alloc_coherent(&(pcidev->dev), @@ -1285,6 +1285,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