From: Jyoti Gupta <jyoti@linux.ibm.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: maddy@linux.ibm.com, mpe@ellerman.id.au, npiggin@gmail.com,
chleroy@kernel.org, ritesh.list@gmail.com, sshegde@linux.ibm.com,
sourabhjain@linux.ibm.com
Subject: [PATCH] powerpc/mpic: Fix memory leak of mpic on error paths
Date: Thu, 24 Sep 2026 12:00:10 +0530 [thread overview]
Message-ID: <20260924063010.188642-1-jyoti@linux.ibm.com> (raw)
mpic_alloc() allocates struct mpic (and optionally the protected
sources bitmap) but does not free them when mpic_setup_error_int() or
irq_domain_create_linear() fails, leaking the memory.
Initialise mpic to NULL and free the bitmap and the mpic in the common
error path before dropping the device node reference. The register
mappings are not released here.
Signed-off-by: Jyoti Gupta <jyoti@linux.ibm.com>
---
arch/powerpc/sysdev/mpic.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index 6e8fa94985f3..e777b33f170d 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -1221,7 +1221,7 @@ struct mpic * __init mpic_alloc(struct device_node *node,
const char *name)
{
int i, psize, intvec_top;
- struct mpic *mpic;
+ struct mpic *mpic = NULL;
u32 greg_feature;
const char *vers;
const u32 *psrc;
@@ -1488,10 +1488,6 @@ struct mpic * __init mpic_alloc(struct device_node *node,
intvec_top,
&mpic_host_ops, mpic);
- /*
- * FIXME: The code leaks the MPIC object and mappings here; this
- * is very unlikely to fail but it ought to be fixed anyways.
- */
if (mpic->irqhost == NULL)
goto err_of_node_put;
@@ -1527,6 +1523,9 @@ struct mpic * __init mpic_alloc(struct device_node *node,
return mpic;
err_of_node_put:
+ if (mpic)
+ bitmap_free(mpic->protected);
+ kfree(mpic);
of_node_put(node);
return NULL;
}
--
2.55.0
next reply other threads:[~2026-09-24 6:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 6:30 Jyoti Gupta [this message]
2026-09-24 9:28 ` [PATCH] powerpc/mpic: Fix memory leak of mpic on error paths Mukesh Kumar Chaurasiya
2026-09-29 6:45 ` jyoti
2026-09-24 9:35 ` Amit Machhiwal
2026-09-29 6:36 ` jyoti
2026-09-29 7:32 ` Amit Machhiwal
-- strict thread matches above, loose matches on Subject: below --
2026-09-30 16:41 Jyoti Gupta
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260924063010.188642-1-jyoti@linux.ibm.com \
--to=jyoti@linux.ibm.com \
--cc=chleroy@kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=ritesh.list@gmail.com \
--cc=sourabhjain@linux.ibm.com \
--cc=sshegde@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.