Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <rodrigo.vivi@intel.com>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: Tejas Upadhyay <tejas.upadhyay@intel.com>
Reviewed-by: Tejas Upadhyay <tejas.upadhyay@intel.com>
Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240828092229.3606503-1-himal.prasad.ghimiray@intel.com
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

authored by

Himal Prasad Ghimiray and committed by
Rodrigo Vivi
c7208416 379cad69

+8 -5
+8 -5
drivers/gpu/drm/xe/xe_ggtt.c
··· 286 286 bool bound; 287 287 int idx; 288 288 289 - if (!node || !node->ggtt) 290 - return; 291 - 292 289 bound = drm_dev_enter(&xe->drm, &idx); 293 290 294 291 mutex_lock(&ggtt->lock); ··· 325 328 */ 326 329 void xe_ggtt_node_remove(struct xe_ggtt_node *node, bool invalidate) 327 330 { 328 - struct xe_ggtt *ggtt = node->ggtt; 329 - struct xe_device *xe = tile_to_xe(ggtt->tile); 331 + struct xe_ggtt *ggtt; 332 + struct xe_device *xe; 333 + 334 + if (!node || !node->ggtt) 335 + return; 336 + 337 + ggtt = node->ggtt; 338 + xe = tile_to_xe(ggtt->tile); 330 339 331 340 node->invalidate_on_remove = invalidate; 332 341