drm/amd/pm: add missing error handling in function smu_v13_0_6_allocate_dpm_context

Check return value to avoid null pointer dereference.

Signed-off-by: Bob Zhou <bob.zhou@amd.com>
Reviewed-by: Yang Wang <kevinyang.wang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
Bob Zhou 2024-05-31 16:21:45 +08:00 committed by Alex Deucher
parent 50151b7f1c
commit 8332f1aaf5

View File

@ -451,6 +451,11 @@ static int smu_v13_0_6_allocate_dpm_context(struct smu_context *smu)
smu_dpm->dpm_policies =
kzalloc(sizeof(struct smu_dpm_policy_ctxt), GFP_KERNEL);
if (!smu_dpm->dpm_policies) {
kfree(smu_dpm->dpm_context);
return -ENOMEM;
}
if (!(smu->adev->flags & AMD_IS_APU)) {
policy = &(smu_dpm->dpm_policies->policies[0]);