diff options
| -rw-r--r-- | drivers/misc/cxl/api.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c index 0c77240ae2fc..729e0851167d 100644 --- a/drivers/misc/cxl/api.c +++ b/drivers/misc/cxl/api.c | |||
| @@ -23,6 +23,7 @@ struct cxl_context *cxl_dev_context_init(struct pci_dev *dev) | |||
| 23 | 23 | ||
| 24 | afu = cxl_pci_to_afu(dev); | 24 | afu = cxl_pci_to_afu(dev); |
| 25 | 25 | ||
| 26 | get_device(&afu->dev); | ||
| 26 | ctx = cxl_context_alloc(); | 27 | ctx = cxl_context_alloc(); |
| 27 | if (IS_ERR(ctx)) | 28 | if (IS_ERR(ctx)) |
| 28 | return ctx; | 29 | return ctx; |
| @@ -31,6 +32,7 @@ struct cxl_context *cxl_dev_context_init(struct pci_dev *dev) | |||
| 31 | rc = cxl_context_init(ctx, afu, false, NULL); | 32 | rc = cxl_context_init(ctx, afu, false, NULL); |
| 32 | if (rc) { | 33 | if (rc) { |
| 33 | kfree(ctx); | 34 | kfree(ctx); |
| 35 | put_device(&afu->dev); | ||
| 34 | return ERR_PTR(-ENOMEM); | 36 | return ERR_PTR(-ENOMEM); |
| 35 | } | 37 | } |
| 36 | cxl_assign_psn_space(ctx); | 38 | cxl_assign_psn_space(ctx); |
| @@ -60,6 +62,8 @@ int cxl_release_context(struct cxl_context *ctx) | |||
| 60 | if (ctx->status != CLOSED) | 62 | if (ctx->status != CLOSED) |
| 61 | return -EBUSY; | 63 | return -EBUSY; |
| 62 | 64 | ||
| 65 | put_device(&ctx->afu->dev); | ||
| 66 | |||
| 63 | cxl_context_free(ctx); | 67 | cxl_context_free(ctx); |
| 64 | 68 | ||
| 65 | return 0; | 69 | return 0; |
| @@ -159,7 +163,6 @@ int cxl_start_context(struct cxl_context *ctx, u64 wed, | |||
| 159 | } | 163 | } |
| 160 | 164 | ||
| 161 | ctx->status = STARTED; | 165 | ctx->status = STARTED; |
| 162 | get_device(&ctx->afu->dev); | ||
| 163 | out: | 166 | out: |
| 164 | mutex_unlock(&ctx->status_mutex); | 167 | mutex_unlock(&ctx->status_mutex); |
| 165 | return rc; | 168 | return rc; |
| @@ -175,12 +178,7 @@ EXPORT_SYMBOL_GPL(cxl_process_element); | |||
| 175 | /* Stop a context. Returns 0 on success, otherwise -Errno */ | 178 | /* Stop a context. Returns 0 on success, otherwise -Errno */ |
| 176 | int cxl_stop_context(struct cxl_context *ctx) | 179 | int cxl_stop_context(struct cxl_context *ctx) |
| 177 | { | 180 | { |
| 178 | int rc; | 181 | return __detach_context(ctx); |
| 179 | |||
| 180 | rc = __detach_context(ctx); | ||
| 181 | if (!rc) | ||
| 182 | put_device(&ctx->afu->dev); | ||
| 183 | return rc; | ||
| 184 | } | 182 | } |
| 185 | EXPORT_SYMBOL_GPL(cxl_stop_context); | 183 | EXPORT_SYMBOL_GPL(cxl_stop_context); |
| 186 | 184 | ||
