Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 041ab0a4 authored by Tom St Denis's avatar Tom St Denis Committed by Alex Deucher
Browse files

drm/amd/amdgpu: Make afmt_init() cleanup if alloc fails (DCEv11)



Updated DCEv11 afmt_init to cleanup if any kzalloc
fails and then return an error code.  Don't continue initializing
the audio stack in that case.

Signed-off-by: default avatarTom St Denis <tom.stdenis@amd.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent c437b9d6
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -1966,7 +1966,7 @@ static void dce_v11_0_afmt_enable(struct drm_encoder *encoder, bool enable)
		  enable ? "En" : "Dis", dig->afmt->offset, amdgpu_encoder->encoder_id);
}

static void dce_v11_0_afmt_init(struct amdgpu_device *adev)
static int dce_v11_0_afmt_init(struct amdgpu_device *adev)
{
	int i;

@@ -1979,9 +1979,17 @@ static void dce_v11_0_afmt_init(struct amdgpu_device *adev)
		if (adev->mode_info.afmt[i]) {
			adev->mode_info.afmt[i]->offset = dig_offsets[i];
			adev->mode_info.afmt[i]->id = i;
		} else {
			int j;
			for (j = 0; j < i; j++) {
				kfree(adev->mode_info.afmt[j]);
				adev->mode_info.afmt[j] = NULL;
			}
			return -ENOMEM;
		}
	}
	return 0;
}

static void dce_v11_0_afmt_fini(struct amdgpu_device *adev)
{
@@ -3009,7 +3017,9 @@ static int dce_v11_0_sw_init(void *handle)
		return -EINVAL;

	/* setup afmt */
	dce_v11_0_afmt_init(adev);
	r = dce_v11_0_afmt_init(adev);
	if (r)
		return r;

	r = dce_v11_0_audio_init(adev);
	if (r)