Skip to content

Commit c5f728d

Browse files
committed
drm/xe: Fix memory leak on xe_alloc_pf_queue failure
Simplify memory unwinding on error also fixing current memory leak that can happen on error. v2: use devm_kcalloc(Matt A) Fixes: 3338e4f ("drm/xe: Use topology to determine page fault queue size") Cc: Matthew Auld <[email protected]> Cc: Matthew Brost <[email protected]> Cc: Rodrigo Vivi <[email protected]> Cc: Stuart Summers <[email protected]> Reviewed-by: Matthew Auld <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Nirmoy Das <[email protected]>
1 parent 2bd87f0 commit c5f728d

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

drivers/gpu/drm/xe/xe_gt_pagefault.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -388,20 +388,17 @@ static void pagefault_fini(void *arg)
388388
{
389389
struct xe_gt *gt = arg;
390390
struct xe_device *xe = gt_to_xe(gt);
391-
int i;
392391

393392
if (!xe->info.has_usm)
394393
return;
395394

396395
destroy_workqueue(gt->usm.acc_wq);
397396
destroy_workqueue(gt->usm.pf_wq);
398-
399-
for (i = 0; i < NUM_PF_QUEUE; ++i)
400-
kfree(gt->usm.pf_queue[i].data);
401397
}
402398

403399
static int xe_alloc_pf_queue(struct xe_gt *gt, struct pf_queue *pf_queue)
404400
{
401+
struct xe_device *xe = gt_to_xe(gt);
405402
xe_dss_mask_t all_dss;
406403
int num_dss, num_eus;
407404

@@ -417,7 +414,8 @@ static int xe_alloc_pf_queue(struct xe_gt *gt, struct pf_queue *pf_queue)
417414
(num_eus + XE_NUM_HW_ENGINES) * PF_MSG_LEN_DW;
418415

419416
pf_queue->gt = gt;
420-
pf_queue->data = kcalloc(pf_queue->num_dw, sizeof(u32), GFP_KERNEL);
417+
pf_queue->data = devm_kcalloc(xe->drm.dev, pf_queue->num_dw,
418+
sizeof(u32), GFP_KERNEL);
421419
if (!pf_queue->data)
422420
return -ENOMEM;
423421

0 commit comments

Comments
 (0)