summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorTom St Denis <tom.stdenis@amd.com>2016-09-22 12:20:58 -0400
committerAlex Deucher <alexander.deucher@amd.com>2016-09-22 14:15:59 -0400
commitbeb86f29c9c7f2d04f9a42c4c61cc469c3689779 (patch)
treeb1ffbabcfcfe095fd8a3451081b93d267a50a0d6 /drivers
parente37e4f057b47ff1e502799062f8ab30156e54bd3 (diff)
drm/amd/amdgpu: Clean up afmt allocation in DCEv6. (v2)
v2: minor build fix Signed-off-by: Tom St Denis <tom.stdenis@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/dce_v6_0.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
index c866185fd091..eb8f96a61491 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
@@ -1422,21 +1422,29 @@ static void dce_v6_0_afmt_enable(struct drm_encoder *encoder, bool enable)
enable ? "En" : "Dis", dig->afmt->offset, amdgpu_encoder->encoder_id);
}
-static void dce_v6_0_afmt_init(struct amdgpu_device *adev)
+static int dce_v6_0_afmt_init(struct amdgpu_device *adev)
{
- int i;
+ int i, j;
for (i = 0; i < adev->mode_info.num_dig; i++)
adev->mode_info.afmt[i] = NULL;
- /* DCE8 has audio blocks tied to DIG encoders */
+ /* DCE6 has audio blocks tied to DIG encoders */
for (i = 0; i < adev->mode_info.num_dig; i++) {
adev->mode_info.afmt[i] = kzalloc(sizeof(struct amdgpu_afmt), GFP_KERNEL);
if (adev->mode_info.afmt[i]) {
adev->mode_info.afmt[i]->offset = dig_offsets[i];
adev->mode_info.afmt[i]->id = i;
+ } else {
+ for (j = 0; j < i; j++) {
+ kfree(adev->mode_info.afmt[j]);
+ adev->mode_info.afmt[j] = NULL;
+ }
+ DRM_ERROR("Out of memory allocating afmt table\n");
+ return -ENOMEM;
}
}
+ return 0;
}
static void dce_v6_0_afmt_fini(struct amdgpu_device *adev)
@@ -2399,7 +2407,9 @@ static int dce_v6_0_sw_init(void *handle)
return -EINVAL;
/* setup afmt */
- dce_v6_0_afmt_init(adev);
+ r = dce_v6_0_afmt_init(adev);
+ if (r)
+ return r;
r = dce_v6_0_audio_init(adev);
if (r)