Skip to content
/ linux Public

Commit c3aa7b8

Browse files
guptavargregkh
authored andcommitted
drm/xe: Fix memory leak in xe_vm_madvise_ioctl
[ Upstream commit 0cfe9c4 ] 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. Fixes: 293032e ("drm/xe/bo: Update atomic_access attribute on madvise") Cc: stable@vger.kernel.org # v6.18+ Reviewed-by: Shuicheng Lin <shuicheng.lin@intel.com> Signed-off-by: Varun Gupta <varun.gupta@intel.com> Reviewed-by: Matthew Brost <matthew.brost@intel.com> Link: https://patch.msgid.link/20260223175145.1532801-1-varun.gupta@intel.com Signed-off-by: Tejas Upadhyay <tejas.upadhyay@intel.com> (cherry picked from commit 29bd06faf727a4b76663e4be0f7d770e2d2a7965) Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com> [ changed old goto target from `madv_fini` to `unlock_vm` ] Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f655467 commit c3aa7b8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/gpu/drm/xe/xe_vm_madvise.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ int xe_vm_madvise_ioctl(struct drm_device *dev, void *data, struct drm_file *fil
390390
madvise_range.num_vmas,
391391
args->atomic.val)) {
392392
err = -EINVAL;
393-
goto unlock_vm;
393+
goto free_vmas;
394394
}
395395
}
396396

@@ -426,6 +426,7 @@ int xe_vm_madvise_ioctl(struct drm_device *dev, void *data, struct drm_file *fil
426426
err_fini:
427427
if (madvise_range.has_bo_vmas)
428428
drm_exec_fini(&exec);
429+
free_vmas:
429430
kfree(madvise_range.vmas);
430431
madvise_range.vmas = NULL;
431432
unlock_vm:

0 commit comments

Comments
 (0)