diff options
author | Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com> | 2024-12-10 14:09:38 +0100 |
---|---|---|
committer | Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com> | 2024-12-19 13:16:21 +0100 |
commit | 6c9ba75f147b24b5c59aac7356a38a0fef664afa (patch) | |
tree | 2240259f09cfcdcdc7b887fd785fe2ccaf369c56 /drivers | |
parent | 4b2efb9db0c22a130bbd1275e489b42c02d08050 (diff) | |
download | lwn-6c9ba75f147b24b5c59aac7356a38a0fef664afa.tar.gz lwn-6c9ba75f147b24b5c59aac7356a38a0fef664afa.zip |
accel/ivpu: Fix memory leak in ivpu_mmu_reserved_context_init()
Add appropriate error handling to ensure all allocated resources are
released upon encountering an error.
Fixes: a74f4d991352 ("accel/ivpu: Defer MMU root page table allocation")
Cc: Karol Wachowski <karol.wachowski@intel.com>
Reviewed-by: Karol Wachowski <karol.wachowski@intel.com>
Reviewed-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
Signed-off-by: Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20241210130939.1575610-3-jacek.lawrynowicz@linux.intel.com
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/accel/ivpu/ivpu_mmu_context.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/accel/ivpu/ivpu_mmu_context.c b/drivers/accel/ivpu/ivpu_mmu_context.c index 891967a95bc3..0af614dfb6f9 100644 --- a/drivers/accel/ivpu/ivpu_mmu_context.c +++ b/drivers/accel/ivpu/ivpu_mmu_context.c @@ -612,18 +612,22 @@ int ivpu_mmu_reserved_context_init(struct ivpu_device *vdev) if (!ivpu_mmu_ensure_pgd(vdev, &vdev->rctx.pgtable)) { ivpu_err(vdev, "Failed to allocate root page table for reserved context\n"); ret = -ENOMEM; - goto unlock; + goto err_ctx_fini; } ret = ivpu_mmu_cd_set(vdev, vdev->rctx.id, &vdev->rctx.pgtable); if (ret) { ivpu_err(vdev, "Failed to set context descriptor for reserved context\n"); - goto unlock; + goto err_ctx_fini; } -unlock: mutex_unlock(&vdev->rctx.lock); return ret; + +err_ctx_fini: + mutex_unlock(&vdev->rctx.lock); + ivpu_mmu_context_fini(vdev, &vdev->rctx); + return ret; } void ivpu_mmu_reserved_context_fini(struct ivpu_device *vdev) |