drm/xe: Fix memory leak in xe_vm_madvise_ioctl
Subsystems (2)
PATCH 1/1 drm/xe: Fix memory leak in xe_vm_madvise_ioctl
When check_bo_args_are_sane() validation fails, jump to the new free_vmas cleanup label to properly free the allocated resources. This ensures proper cleanup in this error path.
Signed-off-by Varun Gupta <[email protected]>
--- drivers/gpu/drm/xe/xe_vm_madvise.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/xe/xe_vm_madvise.c +2 -1
@@ -453,7 +453,7 @@ int xe_vm_madvise_ioctl(struct drm_device *dev, void *data, struct drm_file *fil madvise_range.num_vmas, args->atomic.val)) { err = -EINVAL ; - goto madv_fini; + goto free_vmas; } }
@@ -490,6 +490,7 @@ int xe_vm_madvise_ioctl(struct drm_device *dev, void *data, struct drm_file *fil err_fini:if (madvise_range.has_bo_vmas)drm_exec_fini (&exec); +free_vmas:kfree (madvise_range.vmas); madvise_range.vmas =NULL ; madv_fini:
Signature · 1 line
2.43.0
Matthew Brost
maintainerQuoted 4 lines · Varun Gupta
When
check_bo_args_are_sane()validation fails, jump to the newfree_vmascleanup label to properly free the allocated resources. This ensures proper cleanup in this error path.
Fixes tag, CC stable.
Code looks correct.
Matt
Quoted 29 lines
Signed-off-by Varun Gupta <[email protected]>--- drivers/gpu/drm/xe/xe_vm_madvise.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/xe/xe_vm_madvise.c +2
-1@@ -453,7 +453,7 @@ int xe_vm_madvise_ioctl(struct drm_device *dev, void *data, struct drm_file *fil madvise_range.num_vmas, args->atomic.val)) { err = -EINVAL ; - goto madv_fini; + goto free_vmas; } }@@ -490,6 +490,7 @@ int xe_vm_madvise_ioctl(struct drm_device *dev, void *data, struct drm_file *fil err_fini:if (madvise_range.has_bo_vmas)drm_exec_fini (&exec); +free_vmas:kfree (madvise_range.vmas); madvise_range.vmas =NULL ; madv_fini:Signature · 1 line
2.43.0