From nobody Tue Apr 14 22:38:01 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDA95C19F2C for ; Sun, 31 Jul 2022 12:06:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236701AbiGaMGf (ORCPT ); Sun, 31 Jul 2022 08:06:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229640AbiGaMGd (ORCPT ); Sun, 31 Jul 2022 08:06:33 -0400 Received: from smtp.smtpout.orange.fr (smtp09.smtpout.orange.fr [80.12.242.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C00881145F for ; Sun, 31 Jul 2022 05:06:29 -0700 (PDT) Received: from pop-os.home ([90.11.190.129]) by smtp.orange.fr with ESMTPA id I7iDoiOFNAeI9I7iDoaGld; Sun, 31 Jul 2022 14:06:28 +0200 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Sun, 31 Jul 2022 14:06:28 +0200 X-ME-IP: 90.11.190.129 From: Christophe JAILLET To: Lee Jones , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Benjamin Gaignard Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , Lee Jones , linux-arm-kernel@lists.infradead.org Subject: [PATCH] mfd: fsl-imx25: Fix an error handling path in mx25_tsadc_setup_irq() Date: Sun, 31 Jul 2022 14:06:23 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 --- mx25_tsadc_setup_irq() and mx25_tsadc_unset_irq() are not symetrical. One tests for "(irq <=3D 0)" while the other one tests for "(irq)". If <0 the probe will fails, so that is fine. If =3D=3D0, according to doc platform_get_irq() can't return 0, so that sho= uld be fine as well. That said, I think that the "if (irq)" in mx25_tsadc_unset_irq() can be removed. --- 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; } =20 +static int mx25_tsadc_unset_irq(struct platform_device *pdev) +{ + struct mx25_tsadc *tsadc =3D platform_get_drvdata(pdev); + int irq =3D 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 *p= dev) =20 platform_set_drvdata(pdev, tsadc); =20 - return devm_of_platform_populate(dev); + ret =3D devm_of_platform_populate(dev); + if (ret) + goto err_irq; + + return 0; + +err_irq: + mx25_tsadc_unset_irq(pdev); + + return ret; } =20 static int mx25_tsadc_remove(struct platform_device *pdev) { - struct mx25_tsadc *tsadc =3D platform_get_drvdata(pdev); - int irq =3D 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); =20 return 0; } --=20 2.34.1