Skip to content

Commit 4846856

Browse files
ShuichengLinrodrigovivi
authored andcommitted
drm/xe/hw_engine_group: Avoid call kfree() for drmm_kzalloc()
Memory allocated with drmm_kzalloc() should not be freed using kfree(), as it is managed by the DRM subsystem. The memory will be automatically freed when the associated drm_device is released. These 3 group pointers are allocated using drmm_kzalloc() in hw_engine_group_alloc(), so they don't require manual deallocation. Fixes: 6797906 ("drm/xe/hw_engine_group: Fix potential leak") Cc: Michal Wajdeczko <[email protected]> Cc: Matthew Brost <[email protected]> Signed-off-by: Shuicheng Lin <[email protected]> Reviewed-by: Matthew Brost <[email protected]> Signed-off-by: Michal Wajdeczko <[email protected]> Link: https://lore.kernel.org/r/[email protected] (cherry picked from commit f98de826b418885a21ece67f0f5b921ae759b7bf) Signed-off-by: Rodrigo Vivi <[email protected]>
1 parent a2e1407 commit 4846856

File tree

1 file changed

+6
-22
lines changed

1 file changed

+6
-22
lines changed

drivers/gpu/drm/xe/xe_hw_engine_group.c

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -75,25 +75,18 @@ int xe_hw_engine_setup_groups(struct xe_gt *gt)
7575
enum xe_hw_engine_id id;
7676
struct xe_hw_engine_group *group_rcs_ccs, *group_bcs, *group_vcs_vecs;
7777
struct xe_device *xe = gt_to_xe(gt);
78-
int err;
7978

8079
group_rcs_ccs = hw_engine_group_alloc(xe);
81-
if (IS_ERR(group_rcs_ccs)) {
82-
err = PTR_ERR(group_rcs_ccs);
83-
goto err_group_rcs_ccs;
84-
}
80+
if (IS_ERR(group_rcs_ccs))
81+
return PTR_ERR(group_rcs_ccs);
8582

8683
group_bcs = hw_engine_group_alloc(xe);
87-
if (IS_ERR(group_bcs)) {
88-
err = PTR_ERR(group_bcs);
89-
goto err_group_bcs;
90-
}
84+
if (IS_ERR(group_bcs))
85+
return PTR_ERR(group_bcs);
9186

9287
group_vcs_vecs = hw_engine_group_alloc(xe);
93-
if (IS_ERR(group_vcs_vecs)) {
94-
err = PTR_ERR(group_vcs_vecs);
95-
goto err_group_vcs_vecs;
96-
}
88+
if (IS_ERR(group_vcs_vecs))
89+
return PTR_ERR(group_vcs_vecs);
9790

9891
for_each_hw_engine(hwe, gt, id) {
9992
switch (hwe->class) {
@@ -116,15 +109,6 @@ int xe_hw_engine_setup_groups(struct xe_gt *gt)
116109
}
117110

118111
return 0;
119-
120-
err_group_vcs_vecs:
121-
kfree(group_vcs_vecs);
122-
err_group_bcs:
123-
kfree(group_bcs);
124-
err_group_rcs_ccs:
125-
kfree(group_rcs_ccs);
126-
127-
return err;
128112
}
129113

130114
/**

0 commit comments

Comments
 (0)