From patchwork Sat Oct 22 07:25:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7628 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1107512wrr; Sat, 22 Oct 2022 01:41:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7HaWus1M+X7GVmY4r2s7m9HJPh+fKTuTbO8tOEhxYZLNFxLqPbMlIxITNRqeBoTkZSx5XL X-Received: by 2002:a17:906:9bc5:b0:7a2:8b6a:c4f8 with SMTP id de5-20020a1709069bc500b007a28b6ac4f8mr275356ejc.411.1666428067970; Sat, 22 Oct 2022 01:41:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666428067; cv=none; d=google.com; s=arc-20160816; b=Nd/b3LrfmjwbbtcDBxUq14V4Eold+vf8akquogeJPxIooEW37KLewcNVSlb/fZ+BgU k7OX6MzUJNUIJcHvUA+b7k54BHO+xc+s7oL+xYMQxq8Lvd0DX7kI8s3bgTI7a5khWJSO X7vAif7DT7iRhRWVcMxNTxoui8QNnwSXtLyH7+At6fWv0Ujw/9T4UHMzRn8Z8UcLoFxJ frCtq0ddrx5KV+hDdgMn6mAhKDSJshRujQ3a1pY8T/FTG5E3rr1WMKNK2qkR3fogXnNf gbwF0DgXVqQ3kEuRR51V9iuntjlwroNudDQxZtDd2LDT8ynag6JoY4OLcYVKbqB+Z5hL n8aw== 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=XTIhGMgQ0F1wWDDTAASWJeNHYYCpzlxmNaVF2yvzPXo=; b=qQFGqS1p6ED3NQvNjLe59uv5C112/8/JmJICJBRcHSA0DnlGJfkKNe85ur7zTkVhX7 c1pStVlfu8iBvy6nI2sNF2YHtzhkrx98EWRW+cuY/A45/YpsKtQqPKK8a1z8c0olVXOZ El42Xvh0nHwlFNil13yXN4k7Im5Zkq0sVyrhTq/Ao7aujg1lz7erbgnZ+bdxK46kig6P NCpPZ2QEdF+GuLvtPR+MAW/e+IrAAZrBftEeFQvA30p4tpqr7FqdaOQ9PTaIA8gKCmei HbrzxQGjaC6RzAJUOpPuHjZbjHVI0cfy0VpwuoYmxgq/Rd6bk/V1b+q4pLu5/Khycrdz dfKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sP8xXZwr; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s11-20020a056402520b00b0045db2dcff0esi15659333edd.594.2022.10.22.01.40.39; Sat, 22 Oct 2022 01:41:07 -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=sP8xXZwr; 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 S234089AbiJVIiT (ORCPT + 99 others); Sat, 22 Oct 2022 04:38:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234073AbiJVIdE (ORCPT ); Sat, 22 Oct 2022 04:33:04 -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 BD1D22E5E2F; Sat, 22 Oct 2022 01:03:42 -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 C292260B90; Sat, 22 Oct 2022 07:55:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82CEEC433C1; Sat, 22 Oct 2022 07:55:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666425333; bh=7rNgIZ8t7ZwPJgpss76pj0gV2+cw0OBlIpaZoHxPsnE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sP8xXZwr/dshBvljj74GOvpoZBq9L1K4Uj8Y5ewQ+w3sF68DLDQHy4vZ/SqP4dSii AIEs0lgi2eu0eoQq+txduc2Mf1Kz+Kp2MJqMpekTX1xG3wkbDtsezYInecPGPrRXfT cv9N8que5rqpDSTQQ7YXUnvVqRLgvzRydhWY1vYQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe JAILLET , Lee Jones , Sasha Levin Subject: [PATCH 5.19 467/717] mfd: fsl-imx25: Fix an error handling path in mx25_tsadc_setup_irq() Date: Sat, 22 Oct 2022 09:25:46 +0200 Message-Id: <20221022072518.964308156@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747376478086467690?= X-GMAIL-MSGID: =?utf-8?q?1747376478086467690?= From: Christophe JAILLET [ Upstream commit 3fa9e4cfb55da512ebfd57336fde468830719298 ] If devm_of_platform_populate() fails, some resources need to be released. Introduce a mx25_tsadc_unset_irq() function that undoes mx25_tsadc_setup_irq() and call it both from the new error handling path of the probe and in the remove function. Fixes: a55196eff6d6 ("mfd: fsl-imx25: Use devm_of_platform_populate()") Signed-off-by: Christophe JAILLET Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/d404e04828fc06bcfddf81f9f3e9b4babbe35415.1659269156.git.christophe.jaillet@wanadoo.fr Signed-off-by: Sasha Levin --- drivers/mfd/fsl-imx25-tsadc.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/drivers/mfd/fsl-imx25-tsadc.c b/drivers/mfd/fsl-imx25-tsadc.c index 37e5e02a1d05..85f7982d26d2 100644 --- a/drivers/mfd/fsl-imx25-tsadc.c +++ b/drivers/mfd/fsl-imx25-tsadc.c @@ -84,6 +84,19 @@ static int mx25_tsadc_setup_irq(struct platform_device *pdev, return 0; } +static int mx25_tsadc_unset_irq(struct platform_device *pdev) +{ + struct mx25_tsadc *tsadc = platform_get_drvdata(pdev); + int irq = platform_get_irq(pdev, 0); + + if (irq) { + irq_set_chained_handler_and_data(irq, NULL, NULL); + irq_domain_remove(tsadc->domain); + } + + return 0; +} + static void mx25_tsadc_setup_clk(struct platform_device *pdev, struct mx25_tsadc *tsadc) { @@ -171,18 +184,21 @@ static int mx25_tsadc_probe(struct platform_device *pdev) platform_set_drvdata(pdev, tsadc); - return devm_of_platform_populate(dev); + ret = devm_of_platform_populate(dev); + if (ret) + goto err_irq; + + return 0; + +err_irq: + mx25_tsadc_unset_irq(pdev); + + return ret; } static int mx25_tsadc_remove(struct platform_device *pdev) { - struct mx25_tsadc *tsadc = platform_get_drvdata(pdev); - int irq = platform_get_irq(pdev, 0); - - if (irq) { - irq_set_chained_handler_and_data(irq, NULL, NULL); - irq_domain_remove(tsadc->domain); - } + mx25_tsadc_unset_irq(pdev); return 0; }