]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/amd/pm: add missing error handling in function smu_v13_0_6_allocate_dpm_context
authorBob Zhou <bob.zhou@amd.com>
Fri, 31 May 2024 08:21:45 +0000 (16:21 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 5 Jun 2024 15:25:13 +0000 (11:25 -0400)
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>
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c

index 15c0aa0ad44357de39b170a5be9756820efc0f67..6b8decaf6427736c8893496de0a96db131ff3d49 100644 (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]);