From: Bob Zhou Date: Fri, 31 May 2024 08:21:45 +0000 (+0800) Subject: drm/amd/pm: add missing error handling in function smu_v13_0_6_allocate_dpm_context X-Git-Tag: v6.11-rc1~141^2~25^2~15 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8332f1aaf571bec1c023a3b13ba35c86aaa2524d;p=thirdparty%2Fkernel%2Flinux.git 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 Reviewed-by: Yang Wang Signed-off-by: Alex Deucher --- diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c index 15c0aa0ad4435..6b8decaf64277 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c +++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c @@ -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]);