Commit f5c9df9a authored by Ian Munsie's avatar Ian Munsie Committed by Michael Ellerman

cxl: Fix NULL pointer dereference on kernel contexts with no AFU interrupts

If a kernel context is initialised and does not have any AFU interrupts
allocated it will cause a NULL pointer dereference when the context is
detached since the irq_names list will not have been initialised.

Move the initialisation of the irq_names list into the cxl_context_init
routine so that it will be valid for the entire lifetime of the context
and will not cause a NULL pointer dereference.
Signed-off-by: default avatarIan Munsie <imunsie@au1.ibm.com>
Reviewed-by: default avatarAndrew Donnellan <andrew.donnellan@au1.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 2a4f667a
...@@ -67,6 +67,8 @@ int cxl_context_init(struct cxl_context *ctx, struct cxl_afu *afu, bool master, ...@@ -67,6 +67,8 @@ int cxl_context_init(struct cxl_context *ctx, struct cxl_afu *afu, bool master,
ctx->pending_fault = false; ctx->pending_fault = false;
ctx->pending_afu_err = false; ctx->pending_afu_err = false;
INIT_LIST_HEAD(&ctx->irq_names);
/* /*
* When we have to destroy all contexts in cxl_context_detach_all() we * When we have to destroy all contexts in cxl_context_detach_all() we
* end up with afu_release_irqs() called from inside a * end up with afu_release_irqs() called from inside a
......
...@@ -260,9 +260,6 @@ int afu_allocate_irqs(struct cxl_context *ctx, u32 count) ...@@ -260,9 +260,6 @@ int afu_allocate_irqs(struct cxl_context *ctx, u32 count)
else else
alloc_count = count + 1; alloc_count = count + 1;
/* Initialize the list head to hold irq names */
INIT_LIST_HEAD(&ctx->irq_names);
if ((rc = cxl_ops->alloc_irq_ranges(&ctx->irqs, ctx->afu->adapter, if ((rc = cxl_ops->alloc_irq_ranges(&ctx->irqs, ctx->afu->adapter,
alloc_count))) alloc_count)))
return rc; return rc;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment