Commit 5ddab9f7 authored by Daniel J Blueman's avatar Daniel J Blueman Committed by Greg Kroah-Hartman

drm/vc4: Fix memory leak during BO teardown

commit c0db1b67 upstream.

During BO teardown, an indirect list 'uniform_addr_offsets' wasn't being
freed leading to leaking many 128B allocations. Fix the memory leak by
releasing it at teardown time.

Cc: stable@vger.kernel.org
Fixes: 6d45c81d ("drm/vc4: Add support for branching in shader validation.")
Signed-off-by: default avatarDaniel J Blueman <daniel@quora.org>
Signed-off-by: default avatarEric Anholt <eric@anholt.net>
Reviewed-by: default avatarEric Anholt <eric@anholt.net>
Link: https://patchwork.freedesktop.org/patch/msgid/20180402071035.25356-1-daniel@quora.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 01eabcde
...@@ -80,6 +80,7 @@ static void vc4_bo_destroy(struct vc4_bo *bo) ...@@ -80,6 +80,7 @@ static void vc4_bo_destroy(struct vc4_bo *bo)
struct vc4_dev *vc4 = to_vc4_dev(obj->dev); struct vc4_dev *vc4 = to_vc4_dev(obj->dev);
if (bo->validated_shader) { if (bo->validated_shader) {
kfree(bo->validated_shader->uniform_addr_offsets);
kfree(bo->validated_shader->texture_samples); kfree(bo->validated_shader->texture_samples);
kfree(bo->validated_shader); kfree(bo->validated_shader);
bo->validated_shader = NULL; bo->validated_shader = NULL;
...@@ -328,6 +329,7 @@ void vc4_free_object(struct drm_gem_object *gem_bo) ...@@ -328,6 +329,7 @@ void vc4_free_object(struct drm_gem_object *gem_bo)
} }
if (bo->validated_shader) { if (bo->validated_shader) {
kfree(bo->validated_shader->uniform_addr_offsets);
kfree(bo->validated_shader->texture_samples); kfree(bo->validated_shader->texture_samples);
kfree(bo->validated_shader); kfree(bo->validated_shader);
bo->validated_shader = NULL; bo->validated_shader = NULL;
......
...@@ -874,6 +874,7 @@ vc4_validate_shader(struct drm_gem_cma_object *shader_obj) ...@@ -874,6 +874,7 @@ vc4_validate_shader(struct drm_gem_cma_object *shader_obj)
fail: fail:
kfree(validation_state.branch_targets); kfree(validation_state.branch_targets);
if (validated_shader) { if (validated_shader) {
kfree(validated_shader->uniform_addr_offsets);
kfree(validated_shader->texture_samples); kfree(validated_shader->texture_samples);
kfree(validated_shader); kfree(validated_shader);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment