* [PATCH] cxl: Release irqs if memory allocation fails
@ 2015-08-25 5:34 Vaibhav Jain
2015-08-25 7:26 ` Ian Munsie
2015-08-27 21:58 ` Michael Ellerman
0 siblings, 2 replies; 3+ messages in thread
From: Vaibhav Jain @ 2015-08-25 5:34 UTC (permalink / raw)
To: linuxppc-dev
Cc: imunsie, Michael Neuling, Michael Ellerman,
Benjamin Herrenschmidt, Vaibhav Jain
This minor patch plugs a potential irq leak in case of a memory
allocation failure inside function the afu_allocate_irqs. Presently the
irqs allocated to the context gets leaked if allocation of either
one of context irq_bitmap or irq_names fails.
Signed-off-by: Vaibhav Jain <vaibhav@linux.vnet.ibm.com>
---
drivers/misc/cxl/irq.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/misc/cxl/irq.c b/drivers/misc/cxl/irq.c
index c8f1f9d..e8b887e 100644
--- a/drivers/misc/cxl/irq.c
+++ b/drivers/misc/cxl/irq.c
@@ -421,6 +421,9 @@ int afu_allocate_irqs(struct cxl_context *ctx, u32 count)
int rc, r, i, j = 1;
struct cxl_irq_name *irq_name;
+ /* Initialize the list head to hold irq names */
+ INIT_LIST_HEAD(&ctx->irq_names);
+
if ((rc = cxl_alloc_irq_ranges(&ctx->irqs, ctx->afu->adapter, count)))
return rc;
@@ -432,13 +435,12 @@ int afu_allocate_irqs(struct cxl_context *ctx, u32 count)
ctx->irq_bitmap = kcalloc(BITS_TO_LONGS(count),
sizeof(*ctx->irq_bitmap), GFP_KERNEL);
if (!ctx->irq_bitmap)
- return -ENOMEM;
+ goto out;
/*
* Allocate names first. If any fail, bail out before allocating
* actual hardware IRQs.
*/
- INIT_LIST_HEAD(&ctx->irq_names);
for (r = 1; r < CXL_IRQ_RANGES; r++) {
for (i = 0; i < ctx->irqs.range[r]; i++) {
irq_name = kmalloc(sizeof(struct cxl_irq_name),
@@ -460,6 +462,7 @@ int afu_allocate_irqs(struct cxl_context *ctx, u32 count)
return 0;
out:
+ cxl_release_irq_ranges(&ctx->irqs, ctx->afu->adapter);
afu_irq_name_free(ctx);
return -ENOMEM;
}
--
2.2.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] cxl: Release irqs if memory allocation fails
2015-08-25 5:34 [PATCH] cxl: Release irqs if memory allocation fails Vaibhav Jain
@ 2015-08-25 7:26 ` Ian Munsie
2015-08-27 21:58 ` Michael Ellerman
1 sibling, 0 replies; 3+ messages in thread
From: Ian Munsie @ 2015-08-25 7:26 UTC (permalink / raw)
To: Vaibhav Jain; +Cc: linuxppc-dev, Michael Neuling
Acked-by: Ian Munsie <imunsie@au1.ibm.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: cxl: Release irqs if memory allocation fails
2015-08-25 5:34 [PATCH] cxl: Release irqs if memory allocation fails Vaibhav Jain
2015-08-25 7:26 ` Ian Munsie
@ 2015-08-27 21:58 ` Michael Ellerman
1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2015-08-27 21:58 UTC (permalink / raw)
To: Vaibhav Jain, linuxppc-dev; +Cc: Vaibhav Jain, Michael Neuling, imunsie
On Tue, 2015-25-08 at 05:34:48 UTC, Vaibhav Jain wrote:
> This minor patch plugs a potential irq leak in case of a memory
> allocation failure inside function the afu_allocate_irqs. Presently the
> irqs allocated to the context gets leaked if allocation of either
> one of context irq_bitmap or irq_names fails.
>
> Signed-off-by: Vaibhav Jain <vaibhav@linux.vnet.ibm.com>
> Acked-by: Ian Munsie <imunsie@au1.ibm.com>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/a6897f39660cc07fa78b4459
cheers
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-08-27 21:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-25 5:34 [PATCH] cxl: Release irqs if memory allocation fails Vaibhav Jain
2015-08-25 7:26 ` Ian Munsie
2015-08-27 21:58 ` Michael Ellerman
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).