* [PATCH 1/2] mfd: lp8788: Fix an error handling path in lp8788_probe()
@ 2022-07-31 9:55 Christophe JAILLET
2022-07-31 9:55 ` [PATCH 2/2] mfd: lp8788: Fix an error handling path in lp8788_irq_init() and lp8788_irq_init() Christophe JAILLET
2022-08-10 11:16 ` [PATCH 1/2] mfd: lp8788: Fix an error handling path in lp8788_probe() Lee Jones
0 siblings, 2 replies; 4+ messages in thread
From: Christophe JAILLET @ 2022-07-31 9:55 UTC (permalink / raw)
To: Lee Jones, Samuel Ortiz, Milo Kim
Cc: linux-kernel, kernel-janitors, Christophe JAILLET
Should an error occurs in mfd_add_devices(), some resources need to be
released, as already done in the .remove() function.
Add an error handling path and a lp8788_irq_exit() call to undo a previous
lp8788_irq_init().
Fixes: eea6b7cc53aa ("mfd: Add lp8788 mfd driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/mfd/lp8788.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/mfd/lp8788.c b/drivers/mfd/lp8788.c
index c223d2c6a363..998e8cc408a0 100644
--- a/drivers/mfd/lp8788.c
+++ b/drivers/mfd/lp8788.c
@@ -195,8 +195,16 @@ static int lp8788_probe(struct i2c_client *cl, const struct i2c_device_id *id)
if (ret)
return ret;
- return mfd_add_devices(lp->dev, -1, lp8788_devs,
- ARRAY_SIZE(lp8788_devs), NULL, 0, NULL);
+ ret = mfd_add_devices(lp->dev, -1, lp8788_devs,
+ ARRAY_SIZE(lp8788_devs), NULL, 0, NULL);
+ if (ret)
+ goto err_exit_irq;
+
+ return 0;
+
+err_exit_irq:
+ lp8788_irq_exit(lp);
+ return ret;
}
static int lp8788_remove(struct i2c_client *cl)
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] mfd: lp8788: Fix an error handling path in lp8788_irq_init() and lp8788_irq_init()
2022-07-31 9:55 [PATCH 1/2] mfd: lp8788: Fix an error handling path in lp8788_probe() Christophe JAILLET
@ 2022-07-31 9:55 ` Christophe JAILLET
2022-08-10 11:17 ` Lee Jones
2022-08-10 11:16 ` [PATCH 1/2] mfd: lp8788: Fix an error handling path in lp8788_probe() Lee Jones
1 sibling, 1 reply; 4+ messages in thread
From: Christophe JAILLET @ 2022-07-31 9:55 UTC (permalink / raw)
To: Lee Jones, Samuel Ortiz, Milo Kim
Cc: linux-kernel, kernel-janitors, Christophe JAILLET
In lp8788_irq_init(), if an error occurs after a successful
irq_domain_add_linear() call, it must be undone by a corresponding
irq_domain_remove() call.
irq_domain_remove() should also be called in lp8788_irq_exit() for the same
reason.
Fixes: eea6b7cc53aa ("mfd: Add lp8788 mfd driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/mfd/lp8788-irq.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/mfd/lp8788-irq.c b/drivers/mfd/lp8788-irq.c
index 348439a3fbbd..39006297f3d2 100644
--- a/drivers/mfd/lp8788-irq.c
+++ b/drivers/mfd/lp8788-irq.c
@@ -175,6 +175,7 @@ int lp8788_irq_init(struct lp8788 *lp, int irq)
IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
"lp8788-irq", irqd);
if (ret) {
+ irq_domain_remove(lp->irqdm);
dev_err(lp->dev, "failed to create a thread for IRQ_N\n");
return ret;
}
@@ -188,4 +189,6 @@ void lp8788_irq_exit(struct lp8788 *lp)
{
if (lp->irq)
free_irq(lp->irq, lp->irqdm);
+ if (lp->irqdm)
+ irq_domain_remove(lp->irqdm);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] mfd: lp8788: Fix an error handling path in lp8788_probe()
2022-07-31 9:55 [PATCH 1/2] mfd: lp8788: Fix an error handling path in lp8788_probe() Christophe JAILLET
2022-07-31 9:55 ` [PATCH 2/2] mfd: lp8788: Fix an error handling path in lp8788_irq_init() and lp8788_irq_init() Christophe JAILLET
@ 2022-08-10 11:16 ` Lee Jones
1 sibling, 0 replies; 4+ messages in thread
From: Lee Jones @ 2022-08-10 11:16 UTC (permalink / raw)
To: Christophe JAILLET; +Cc: Samuel Ortiz, Milo Kim, linux-kernel, kernel-janitors
On Sun, 31 Jul 2022, Christophe JAILLET wrote:
> Should an error occurs in mfd_add_devices(), some resources need to be
> released, as already done in the .remove() function.
>
> Add an error handling path and a lp8788_irq_exit() call to undo a previous
> lp8788_irq_init().
>
> Fixes: eea6b7cc53aa ("mfd: Add lp8788 mfd driver")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> drivers/mfd/lp8788.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
Applied, thanks.
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] mfd: lp8788: Fix an error handling path in lp8788_irq_init() and lp8788_irq_init()
2022-07-31 9:55 ` [PATCH 2/2] mfd: lp8788: Fix an error handling path in lp8788_irq_init() and lp8788_irq_init() Christophe JAILLET
@ 2022-08-10 11:17 ` Lee Jones
0 siblings, 0 replies; 4+ messages in thread
From: Lee Jones @ 2022-08-10 11:17 UTC (permalink / raw)
To: Christophe JAILLET; +Cc: Samuel Ortiz, Milo Kim, linux-kernel, kernel-janitors
On Sun, 31 Jul 2022, Christophe JAILLET wrote:
> In lp8788_irq_init(), if an error occurs after a successful
> irq_domain_add_linear() call, it must be undone by a corresponding
> irq_domain_remove() call.
>
> irq_domain_remove() should also be called in lp8788_irq_exit() for the same
> reason.
>
> Fixes: eea6b7cc53aa ("mfd: Add lp8788 mfd driver")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> drivers/mfd/lp8788-irq.c | 3 +++
> 1 file changed, 3 insertions(+)
Applied, thanks.
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-08-10 11:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-31 9:55 [PATCH 1/2] mfd: lp8788: Fix an error handling path in lp8788_probe() Christophe JAILLET
2022-07-31 9:55 ` [PATCH 2/2] mfd: lp8788: Fix an error handling path in lp8788_irq_init() and lp8788_irq_init() Christophe JAILLET
2022-08-10 11:17 ` Lee Jones
2022-08-10 11:16 ` [PATCH 1/2] mfd: lp8788: Fix an error handling path in lp8788_probe() Lee Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox