From: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
To: linuxppc-dev@ozlabs.org
Cc: imunsie@au1.ibm.com, mikey@neuling.org,
vaibhav@linux.vnet.ibm.com, mrochs@linux.vnet.ibm.com
Subject: [PATCH 2/3] cxl: fix leak of ctx->irq_bitmap when releasing context via kernel API
Date: Wed, 30 Sep 2015 11:58:06 +1000 [thread overview]
Message-ID: <1443578287-7847-2-git-send-email-andrew.donnellan@au1.ibm.com> (raw)
In-Reply-To: <1443578287-7847-1-git-send-email-andrew.donnellan@au1.ibm.com>
At present, ctx->irq_bitmap is freed in afu_release_irqs(), which is called
from afu_release() via cxl_context_detach().
Move the freeing of ctx->irq_bitmap from afu_release_irqs() to
reclaim_ctx() (called through cxl_context_free()) so it's freed when
releasing a context via the kernel API (cxl_release_context()) or the
userspace API (afu_release()).
Reported-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Fixes: 6f7f0b3df6d4 ("cxl: Add AFU virtual PHB and kernel API")
Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
---
drivers/misc/cxl/context.c | 3 +++
drivers/misc/cxl/irq.c | 2 --
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/misc/cxl/context.c b/drivers/misc/cxl/context.c
index e762f85..2faa127 100644
--- a/drivers/misc/cxl/context.c
+++ b/drivers/misc/cxl/context.c
@@ -275,6 +275,9 @@ static void reclaim_ctx(struct rcu_head *rcu)
if (ctx->kernelapi)
kfree(ctx->mapping);
+ if (ctx->irq_bitmap)
+ kfree(ctx->irq_bitmap);
+
kfree(ctx);
}
diff --git a/drivers/misc/cxl/irq.c b/drivers/misc/cxl/irq.c
index 38b57d6..09a4060 100644
--- a/drivers/misc/cxl/irq.c
+++ b/drivers/misc/cxl/irq.c
@@ -524,7 +524,5 @@ void afu_release_irqs(struct cxl_context *ctx, void *cookie)
afu_irq_name_free(ctx);
cxl_release_irq_ranges(&ctx->irqs, ctx->afu->adapter);
- kfree(ctx->irq_bitmap);
- ctx->irq_bitmap = NULL;
ctx->irq_count = 0;
}
--
Andrew Donnellan Software Engineer, OzLabs
andrew.donnellan@au1.ibm.com Australia Development Lab, Canberra
+61 2 6201 8874 (work) IBM Australia Limited
next prev parent reply other threads:[~2015-09-30 1:59 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-30 1:58 [PATCH 1/3] cxl: fix leak of IRQ names in cxl_free_afu_irqs() Andrew Donnellan
2015-09-30 1:58 ` Andrew Donnellan [this message]
2015-09-30 6:01 ` [PATCH 2/3] cxl: fix leak of ctx->irq_bitmap when releasing context via kernel API Ian Munsie
2015-09-30 14:04 ` Matthew R. Ochs
2015-10-01 6:51 ` [2/3] " Michael Ellerman
2015-09-30 1:58 ` [PATCH 3/3] cxl: fix leak of ctx->mapping when releasing kernel API contexts Andrew Donnellan
2015-09-30 6:02 ` Ian Munsie
2015-09-30 14:04 ` Matthew R. Ochs
2015-10-01 6:51 ` [3/3] " Michael Ellerman
2015-10-07 10:10 ` Michael Ellerman
2015-09-30 14:03 ` [PATCH 1/3] cxl: fix leak of IRQ names in cxl_free_afu_irqs() Matthew R. Ochs
2015-10-01 6:49 ` [1/3] " Michael Ellerman
2015-10-01 6:51 ` Michael Ellerman
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=1443578287-7847-2-git-send-email-andrew.donnellan@au1.ibm.com \
--to=andrew.donnellan@au1.ibm.com \
--cc=imunsie@au1.ibm.com \
--cc=linuxppc-dev@ozlabs.org \
--cc=mikey@neuling.org \
--cc=mrochs@linux.vnet.ibm.com \
--cc=vaibhav@linux.vnet.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 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).