From c72084163cd22ebf59d936669ec25b1fc2b7494c Mon Sep 17 00:00:00 2001 From: Himal Prasad Ghimiray Date: Wed, 28 Aug 2024 14:52:29 +0530 Subject: [PATCH] drm/xe: Fix NPD in ggtt_node_remove() Make sure that ggtt_node_remove() is invoked only if both node and ggtt are not null. Move the null checks to the caller function xe_ggtt_node_remove(). v2: Move null check below declarations (Tejas) Fixes: 919bb54e989c ("drm/xe: Fix missing runtime outer protection for ggtt_remove_node") Cc: Rodrigo Vivi Cc: Lucas De Marchi Cc: Tejas Upadhyay Reviewed-by: Tejas Upadhyay Signed-off-by: Himal Prasad Ghimiray Link: https://patchwork.freedesktop.org/patch/msgid/20240828092229.3606503-1-himal.prasad.ghimiray@intel.com Signed-off-by: Rodrigo Vivi --- drivers/gpu/drm/xe/xe_ggtt.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c index 86fc6afa43bd9..f3fca5565d320 100644 --- a/drivers/gpu/drm/xe/xe_ggtt.c +++ b/drivers/gpu/drm/xe/xe_ggtt.c @@ -286,9 +286,6 @@ static void ggtt_node_remove(struct xe_ggtt_node *node) bool bound; int idx; - if (!node || !node->ggtt) - return; - bound = drm_dev_enter(&xe->drm, &idx); mutex_lock(&ggtt->lock); @@ -328,8 +325,14 @@ static void ggtt_node_remove_work_func(struct work_struct *work) */ void xe_ggtt_node_remove(struct xe_ggtt_node *node, bool invalidate) { - struct xe_ggtt *ggtt = node->ggtt; - struct xe_device *xe = tile_to_xe(ggtt->tile); + struct xe_ggtt *ggtt; + struct xe_device *xe; + + if (!node || !node->ggtt) + return; + + ggtt = node->ggtt; + xe = tile_to_xe(ggtt->tile); node->invalidate_on_remove = invalidate;