]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/xe: Fix memory leak in xe_vm_madvise_ioctl
authorVarun Gupta <varun.gupta@intel.com>
Mon, 23 Feb 2026 17:51:45 +0000 (23:21 +0530)
committerTejas Upadhyay <tejas.upadhyay@intel.com>
Tue, 3 Mar 2026 12:49:01 +0000 (18:19 +0530)
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: 293032eec4ba ("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>
drivers/gpu/drm/xe/xe_vm_madvise.c

index 52147f5eaaa07b0a49c93b5027492611beebab86..0c92fed6c6a62e6daf2fc1447f5bde05be7f1d5f 100644 (file)
@@ -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: