Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] drm/xe/gsc: Fix double-free of managed BO in error path
  2026-04-17 16:18 [PATCH 0/2] drm/xe: Fix double-free of managed BOs in error paths Shuicheng Lin
@ 2026-04-17 16:19 ` Shuicheng Lin
  0 siblings, 0 replies; 3+ messages in thread
From: Shuicheng Lin @ 2026-04-17 16:19 UTC (permalink / raw)
  To: intel-xe; +Cc: Shuicheng Lin, Daniele Ceraolo Spurio

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 <daniele.ceraolospurio@intel.com>
Assisted-by: Claude:claude-opus-4.6
Signed-off-by: Shuicheng Lin <shuicheng.lin@intel.com>
---
 drivers/gpu/drm/xe/xe_gsc.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_gsc.c b/drivers/gpu/drm/xe/xe_gsc.c
index 0d13e357fb43..aab59dc647fb 100644
--- a/drivers/gpu/drm/xe/xe_gsc.c
+++ b/drivers/gpu/drm/xe/xe_gsc.c
@@ -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;
 }
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 1/2] drm/xe/gsc: Fix double-free of managed BO in error path
@ 2026-04-27 15:46 Shuicheng Lin
  2026-04-28 23:06 ` Daniele Ceraolo Spurio
  0 siblings, 1 reply; 3+ messages in thread
From: Shuicheng Lin @ 2026-04-27 15:46 UTC (permalink / raw)
  To: intel-xe; +Cc: Shuicheng Lin, Daniele Ceraolo Spurio

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 <daniele.ceraolospurio@intel.com>
Assisted-by: Claude:claude-opus-4.6
Signed-off-by: Shuicheng Lin <shuicheng.lin@intel.com>
---
 drivers/gpu/drm/xe/xe_gsc.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_gsc.c b/drivers/gpu/drm/xe/xe_gsc.c
index 0d13e357fb43..aab59dc647fb 100644
--- a/drivers/gpu/drm/xe/xe_gsc.c
+++ b/drivers/gpu/drm/xe/xe_gsc.c
@@ -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;
 }
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] drm/xe/gsc: Fix double-free of managed BO in error path
  2026-04-27 15:46 [PATCH 1/2] drm/xe/gsc: Fix double-free of managed BO in error path Shuicheng Lin
@ 2026-04-28 23:06 ` Daniele Ceraolo Spurio
  0 siblings, 0 replies; 3+ messages in thread
From: Daniele Ceraolo Spurio @ 2026-04-28 23:06 UTC (permalink / raw)
  To: Shuicheng Lin, intel-xe



On 4/27/2026 8:46 AM, Shuicheng Lin wrote:
> 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 <daniele.ceraolospurio@intel.com>
> Assisted-by: Claude:claude-opus-4.6
> Signed-off-by: Shuicheng Lin <shuicheng.lin@intel.com>

Reviewed-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>

Daniele

> ---
>   drivers/gpu/drm/xe/xe_gsc.c | 5 +----
>   1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_gsc.c b/drivers/gpu/drm/xe/xe_gsc.c
> index 0d13e357fb43..aab59dc647fb 100644
> --- a/drivers/gpu/drm/xe/xe_gsc.c
> +++ b/drivers/gpu/drm/xe/xe_gsc.c
> @@ -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;
>   }
>   


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-04-28 23:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-27 15:46 [PATCH 1/2] drm/xe/gsc: Fix double-free of managed BO in error path Shuicheng Lin
2026-04-28 23:06 ` Daniele Ceraolo Spurio
  -- strict thread matches above, loose matches on Subject: below --
2026-04-17 16:18 [PATCH 0/2] drm/xe: Fix double-free of managed BOs in error paths Shuicheng Lin
2026-04-17 16:19 ` [PATCH 1/2] drm/xe/gsc: Fix double-free of managed BO in error path Shuicheng Lin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox