* [PATCH] mfd: fsl-imx25: Fix an error handling path in mx25_tsadc_setup_irq()
@ 2022-07-31 12:06 Christophe JAILLET
2022-08-10 11:14 ` Lee Jones
0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2022-07-31 12:06 UTC (permalink / raw)
To: Lee Jones, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, NXP Linux Team, Benjamin Gaignard
Cc: linux-kernel, kernel-janitors, Christophe JAILLET, Lee Jones,
linux-arm-kernel
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 <christophe.jaillet@wanadoo.fr>
---
mx25_tsadc_setup_irq() and mx25_tsadc_unset_irq() are not symetrical.
One tests for "(irq <= 0)" while the other one tests for "(irq)".
If <0 the probe will fails, so that is fine.
If ==0, according to doc platform_get_irq() can't return 0, so that should
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;
}
+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;
}
--
2.34.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mfd: fsl-imx25: Fix an error handling path in mx25_tsadc_setup_irq()
2022-07-31 12:06 [PATCH] mfd: fsl-imx25: Fix an error handling path in mx25_tsadc_setup_irq() Christophe JAILLET
@ 2022-08-10 11:14 ` Lee Jones
0 siblings, 0 replies; 2+ messages in thread
From: Lee Jones @ 2022-08-10 11:14 UTC (permalink / raw)
To: Christophe JAILLET
Cc: Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
NXP Linux Team, Benjamin Gaignard, linux-kernel, kernel-janitors,
Lee Jones, linux-arm-kernel
On Sun, 31 Jul 2022, Christophe JAILLET wrote:
> 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 <christophe.jaillet@wanadoo.fr>
> ---
> mx25_tsadc_setup_irq() and mx25_tsadc_unset_irq() are not symetrical.
> One tests for "(irq <= 0)" while the other one tests for "(irq)".
>
> If <0 the probe will fails, so that is fine.
> If ==0, according to doc platform_get_irq() can't return 0, so that should
> 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(-)
Applied, thanks.
--
Lee Jones [李琼斯]
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-08-10 11:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-31 12:06 [PATCH] mfd: fsl-imx25: Fix an error handling path in mx25_tsadc_setup_irq() Christophe JAILLET
2022-08-10 11:14 ` Lee Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).