From 5f058063197cd9db5ea73807223ea0df28ebfb82 Mon Sep 17 00:00:00 2001 From: Shuicheng Lin Date: Tue, 15 Sep 2026 01:12:29 +0000 Subject: [PATCH] drm/xe/madvise: Remove unreachable madvise_funcs NULL check The NULL check on madvise_funcs[attr_type] in xe_vm_madvise_ioctl() is unreachable. madvise_args_are_sane() already validates args->type via a switch statement whose default case rejects any type not present in madvise_funcs[]. Every type that passes the sanity check has a corresponding entry in the table. Beyond being dead code, the check's error path (goto err_fini) would also skip xe_svm_notifier_unlock() if it were somehow reached with has_svm_userptr_vmas set, since err_fini only tears down the drm_exec. Removing the check eliminates both the redundancy and the latent unwind hazard. No functional change. Assisted-by: LLM Reviewed-by: Xin Wang Link: https://patch.msgid.link/20260915011229.203424-1-shuicheng.lin@intel.com Signed-off-by: Shuicheng Lin --- drivers/gpu/drm/xe/xe_vm_madvise.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_vm_madvise.c b/drivers/gpu/drm/xe/xe_vm_madvise.c index 0474768a38aa..5c7aefc641ee 100644 --- a/drivers/gpu/drm/xe/xe_vm_madvise.c +++ b/drivers/gpu/drm/xe/xe_vm_madvise.c @@ -713,12 +713,6 @@ int xe_vm_madvise_ioctl(struct drm_device *dev, void *data, struct drm_file *fil attr_type = array_index_nospec(args->type, ARRAY_SIZE(madvise_funcs)); - /* Ensure the madvise function exists for this type */ - if (!madvise_funcs[attr_type]) { - err = -EINVAL; - goto err_fini; - } - madvise_funcs[attr_type](xe, vm, madvise_range.vmas, madvise_range.num_vmas, args, &details);