Skip to contentSkip to conversation

drm/xe/gsc: Fix double-free of managed BO in error path

PATCH In review Shuicheng Lin 2 participants 2 messages Apr 27 – Apr 28

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm/xe/gsc: Fix double-free of managed BO in error path

The error path in xe_gsc_init_post_hwconfig() explicitly frees a BO allocated with xe_managed_bo_create_pin_map() via xe_bo_unpin_map_no_vm(). Since the managed BO already has a devm cleanup action registered, this causes a double-free when devm unwinds during probe failure.

Remove the explicit free and let devm handle it, consistent with all other xe_managed_bo_create_pin_map() callers.

Fixes 2e5d47fe7839 ("drm/xe/uc: Use managed bo for HuC and GSC objects")
Cc Daniele Ceraolo Spurio <[email protected]>
Assisted-by Claude:claude-opus-4.6
---
 drivers/gpu/drm/xe/xe_gsc.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/gpu/drm/xe/xe_gsc.c +1 -4
index 0d13e357fb43..aab59dc647fb 100644
@@ -482,8 +482,7 @@ int xe_gsc_init_post_hwconfig(struct xe_gsc *gsc)
 				 EXEC_QUEUE_FLAG_PERMANENT, 0);
 	if (IS_ERR(q)) {
 		xe_gt_err(gt, "Failed to create queue for GSC submission\n");
-		err = PTR_ERR(q);
-		goto out_bo;
+		return PTR_ERR(q);
 	}
 
 	wq = alloc_ordered_workqueue("gsc-ordered-wq", 0);
@@ -506,8 +505,6 @@ int xe_gsc_init_post_hwconfig(struct xe_gsc *gsc)
 
 out_q:
 	xe_exec_queue_put(q);
-out_bo:
-	xe_bo_unpin_map_no_vm(bo);
 	return err;
 }
 
Signature · 1 line
2.43.0
Reviewed-by on v1 1/2
#1 lore raw
Quoted 6 lines · Shuicheng Lin

The error path in xe_gsc_init_post_hwconfig() explicitly frees a BO allocated with xe_managed_bo_create_pin_map() via xe_bo_unpin_map_no_vm(). Since the managed BO already has a devm cleanup action registered, this causes a double-free when devm unwinds during probe failure.

Quoted 7 lines

Remove the explicit free and let devm handle it, consistent with all other xe_managed_bo_create_pin_map() callers.

Fixes 2e5d47fe7839 ("drm/xe/uc: Use managed bo for HuC and GSC objects")
Cc Daniele Ceraolo Spurio <[email protected]>
Assisted-by Claude:claude-opus-4.6

Daniele

Quoted 27 lines
---
  drivers/gpu/drm/xe/xe_gsc.c | 5 +----
  1 file changed, 1 insertion(+), 4 deletions(-)
drivers/gpu/drm/xe/xe_gsc.c +1 -4
index 0d13e357fb43..aab59dc647fb 100644
@@ -482,8 +482,7 @@ int xe_gsc_init_post_hwconfig(struct xe_gsc *gsc)
  				 EXEC_QUEUE_FLAG_PERMANENT, 0);
  	if (IS_ERR(q)) {
  		xe_gt_err(gt, "Failed to create queue for GSC submission\n");
-		err = PTR_ERR(q);
-		goto out_bo;
+		return PTR_ERR(q);
  	}
 
  	wq = alloc_ordered_workqueue("gsc-ordered-wq", 0);
@@ -506,8 +505,6 @@ int xe_gsc_init_post_hwconfig(struct xe_gsc *gsc)
 
  out_q:
  	xe_exec_queue_put(q);
-out_bo:
-	xe_bo_unpin_map_no_vm(bo);
  	return err;
  }