Skip to content

Commit 6c9ba75

Browse files
committed
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: a74f4d9 ("accel/ivpu: Defer MMU root page table allocation") Cc: Karol Wachowski <[email protected]> Reviewed-by: Karol Wachowski <[email protected]> Reviewed-by: Jeffrey Hugo <[email protected]> Signed-off-by: Jacek Lawrynowicz <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 4b2efb9 commit 6c9ba75

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

drivers/accel/ivpu/ivpu_mmu_context.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -612,18 +612,22 @@ int ivpu_mmu_reserved_context_init(struct ivpu_device *vdev)
612612
if (!ivpu_mmu_ensure_pgd(vdev, &vdev->rctx.pgtable)) {
613613
ivpu_err(vdev, "Failed to allocate root page table for reserved context\n");
614614
ret = -ENOMEM;
615-
goto unlock;
615+
goto err_ctx_fini;
616616
}
617617

618618
ret = ivpu_mmu_cd_set(vdev, vdev->rctx.id, &vdev->rctx.pgtable);
619619
if (ret) {
620620
ivpu_err(vdev, "Failed to set context descriptor for reserved context\n");
621-
goto unlock;
621+
goto err_ctx_fini;
622622
}
623623

624-
unlock:
625624
mutex_unlock(&vdev->rctx.lock);
626625
return ret;
626+
627+
err_ctx_fini:
628+
mutex_unlock(&vdev->rctx.lock);
629+
ivpu_mmu_context_fini(vdev, &vdev->rctx);
630+
return ret;
627631
}
628632

629633
void ivpu_mmu_reserved_context_fini(struct ivpu_device *vdev)

0 commit comments

Comments
 (0)