Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp7517884rwi; Mon, 24 Oct 2022 16:07:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM536PpYI5SP+vJj5QAJgYNfhKKdoVoVRxyvdMDcWuLk+v11uDKAB8opI6DWHg4nT5zvq8O7 X-Received: by 2002:a05:6402:e01:b0:442:dd7e:f49d with SMTP id h1-20020a0564020e0100b00442dd7ef49dmr32298598edh.355.1666652827331; Mon, 24 Oct 2022 16:07:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666652827; cv=none; d=google.com; s=arc-20160816; b=Lio4hAolpMiwvttyxrTb4lrbOHusKcJibdyohtCBMDo6oVi3ak/y/NB8gkv7C796Jb Kp4GOvcjgEUBpS504anD/UkRvofq3oGA8o4Yp/QnYHNEE56u/QsBJpCeYkRhDxJGq7/q EQaP6bVEnHG0eQ5fMCmtYrExHiXjIKn0cyZB+TsaxOM6MIdtOVPqPtif+2e8jJc0zQXm kiPa6AZpP6vl226DkZDEXnqdScg0JRsu0avp7a2yYS1BHqc6yL5rqy7Vw2/c1EjUthl0 WEHpFp2yQ8hZCFRqZ9Dz6EGgkLqjFM/MU43XffPg1T2XMslVysE0L5TFXzXMK6y4znHo 7ugQ== 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=eLazDWmfyIuSzChC/l4miwSYUjp+PM7PS0a65SPPiBo=; b=tWMxSLQ0vvFBJ8IEdtSHfKxrys+ccC75kj6kJ3J8kS6TtmQc4aP4wehJO3IkeBJWDM FjgVx8XtW4hd0JaI+CWhRKbzumkSGpy72xEIR08rmXLVg32oJgghqrm7D9eLEx1HTQpy dUqTWtMHnigjZHan1SciGfjKhZDdhB5tZLC1SBRoBDJHa8xk7J0kfV/OH4ct4I3Nmc7H ud45IXtmT8gAhpUi/lZltJ/ELnO6koVcKuiXiBuJgT2l5SCrhYvMvk70IWiIbaQHJ2Yy tx0Cpgo+qpYaRCVMPjDb+BgZi+aF+Wy0pIDpsnJjAjEw27dSqLrtkqCgaiy9kYHwF67u Ctjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Oq8QZveW; 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 hv19-20020a17090760d300b0078e1d213831si1124570ejc.122.2022.10.24.16.06.41; Mon, 24 Oct 2022 16:07: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=Oq8QZveW; 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 S230460AbiJXWUP (ORCPT + 99 others); Mon, 24 Oct 2022 18:20:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230385AbiJXWTf (ORCPT ); Mon, 24 Oct 2022 18:19:35 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00C4431284A; Mon, 24 Oct 2022 13:37:49 -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 9DBC4B81193; Mon, 24 Oct 2022 11:51:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ECE0FC433C1; Mon, 24 Oct 2022 11:51:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612292; bh=DZ+Zu5WpqihCLIpHxBVl2RjarTF9WSJjeuJbrVDk70k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Oq8QZveW60kqKacMMkplK2UIsvBSUok2X6fjRuOYTq4fdM8Rqfu/SB9dj/o9bz6v5 Ol2QlNQd3Lf/fnGez41BB0svoqbdHbALOl+wNBBCRH4PDQ8PmrCR1h/WumOYMPeRjv R6HeUCMCPIz1aGfu0dCQUtparnx6fPo7fS7frOCs= 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 4.14 143/210] mfd: fsl-imx25: Fix an error handling path in mx25_tsadc_setup_irq() Date: Mon, 24 Oct 2022 13:31:00 +0200 Message-Id: <20221024113001.618428914@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112956.797777597@linuxfoundation.org> References: <20221024112956.797777597@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.6 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 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 461b0990b56f..5ad721035e49 100644 --- a/drivers/mfd/fsl-imx25-tsadc.c +++ b/drivers/mfd/fsl-imx25-tsadc.c @@ -90,6 +90,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) { @@ -177,18 +190,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; } -- 2.35.1