* [PATCH] powerpc/powermac: Use common error handling code in kw_i2c_host_init()
@ 2026-06-10 17:56 Markus Elfring
0 siblings, 0 replies; only message in thread
From: Markus Elfring @ 2026-06-10 17:56 UTC (permalink / raw)
To: linuxppc-dev, Bart Van Assche, Christophe Leroy, Kees Cook,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 10 Jun 2026 19:50:08 +0200
Use an additional label so that a bit of exception handling can be better
reused at the end of this function implementation.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
arch/powerpc/platforms/powermac/low_i2c.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/arch/powerpc/platforms/powermac/low_i2c.c b/arch/powerpc/platforms/powermac/low_i2c.c
index da72a30ab865..8daf389d72e9 100644
--- a/arch/powerpc/platforms/powermac/low_i2c.c
+++ b/arch/powerpc/platforms/powermac/low_i2c.c
@@ -504,8 +504,7 @@ static struct pmac_i2c_host_kw *__init kw_i2c_host_init(struct device_node *np)
if (addrp == NULL) {
printk(KERN_ERR "low_i2c: Can't find address for %pOF\n",
np);
- kfree(host);
- return NULL;
+ goto free_host;
}
mutex_init(&host->mutex);
init_completion(&host->complete);
@@ -540,8 +539,7 @@ static struct pmac_i2c_host_kw *__init kw_i2c_host_init(struct device_node *np)
if (host->base == NULL) {
printk(KERN_ERR "low_i2c: Can't map registers for %pOF\n",
np);
- kfree(host);
- return NULL;
+ goto free_host;
}
/* Make sure IRQ is disabled */
@@ -559,6 +557,10 @@ static struct pmac_i2c_host_kw *__init kw_i2c_host_init(struct device_node *np)
*addrp, host->irq, np);
return host;
+
+free_host:
+ kfree(host);
+ return NULL;
}
--
2.54.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-06-10 18:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-10 17:56 [PATCH] powerpc/powermac: Use common error handling code in kw_i2c_host_init() Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox