aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/cxl/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/misc/cxl/file.c')
-rw-r--r--drivers/misc/cxl/file.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/drivers/misc/cxl/file.c b/drivers/misc/cxl/file.c
index a30bf285b5bd..7ccd2998be92 100644
--- a/drivers/misc/cxl/file.c
+++ b/drivers/misc/cxl/file.c
@@ -120,9 +120,16 @@ int afu_release(struct inode *inode, struct file *file)
120 __func__, ctx->pe); 120 __func__, ctx->pe);
121 cxl_context_detach(ctx); 121 cxl_context_detach(ctx);
122 122
123 mutex_lock(&ctx->mapping_lock); 123
124 ctx->mapping = NULL; 124 /*
125 mutex_unlock(&ctx->mapping_lock); 125 * Delete the context's mapping pointer, unless it's created by the
126 * kernel API, in which case leave it so it can be freed by reclaim_ctx()
127 */
128 if (!ctx->kernelapi) {
129 mutex_lock(&ctx->mapping_lock);
130 ctx->mapping = NULL;
131 mutex_unlock(&ctx->mapping_lock);
132 }
126 133
127 put_device(&ctx->afu->dev); 134 put_device(&ctx->afu->dev);
128 135