Skip to content

Commit ec8f181

Browse files
Akhil P Oommenrobclark
authored andcommitted
drm/msm/a6xx: Replace kcalloc() with kvzalloc()
In order to reduce chance of allocation failure while capturing a6xx gpu state, use kvzalloc() instead of kcalloc() in state_kcalloc(). Indirectly, this patch helps to fix leaking memory allocated for gmu_debug object. Fixes: b859f9b (drm/msm/gpu: Snapshot GMU debug buffer) Signed-off-by: Akhil P Oommen <[email protected]> Patchwork: https://patchwork.freedesktop.org/patch/505074/ Link: https://lore.kernel.org/r/20220928124830.1.I8ea24a8d586b4978823b848adde000f92f74d5c2@changeid Signed-off-by: Rob Clark <[email protected]>
1 parent 084b9e1 commit ec8f181

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ struct a6xx_state_memobj {
9191
static void *state_kcalloc(struct a6xx_gpu_state *a6xx_state, int nr, size_t objsize)
9292
{
9393
struct a6xx_state_memobj *obj =
94-
kzalloc((nr * objsize) + sizeof(*obj), GFP_KERNEL);
94+
kvzalloc((nr * objsize) + sizeof(*obj), GFP_KERNEL);
9595

9696
if (!obj)
9797
return NULL;
@@ -819,7 +819,7 @@ static struct msm_gpu_state_bo *a6xx_snapshot_gmu_bo(
819819

820820
snapshot->iova = bo->iova;
821821
snapshot->size = bo->size;
822-
snapshot->data = kvzalloc(snapshot->size, GFP_KERNEL);
822+
snapshot->data = state_kcalloc(a6xx_state, 1, snapshot->size);
823823
if (!snapshot->data)
824824
return NULL;
825825

@@ -1034,14 +1034,8 @@ static void a6xx_gpu_state_destroy(struct kref *kref)
10341034
struct a6xx_gpu_state *a6xx_state = container_of(state,
10351035
struct a6xx_gpu_state, base);
10361036

1037-
if (a6xx_state->gmu_log)
1038-
kvfree(a6xx_state->gmu_log->data);
1039-
1040-
if (a6xx_state->gmu_hfi)
1041-
kvfree(a6xx_state->gmu_hfi->data);
1042-
10431037
list_for_each_entry_safe(obj, tmp, &a6xx_state->objs, node)
1044-
kfree(obj);
1038+
kvfree(obj);
10451039

10461040
adreno_gpu_state_destroy(state);
10471041
kfree(a6xx_state);

0 commit comments

Comments
 (0)