Check return value to avoid null pointer dereference.

Signed-off-by: Bob Zhou <[email protected]>
---
 drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c | 3 +++
 1 file changed, 3 insertions(+)

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 15c0aa0ad443..419e46cfa065 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,9 @@ 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)
+               return -ENOMEM;
+
        if (!(smu->adev->flags & AMD_IS_APU)) {
                policy = &(smu_dpm->dpm_policies->policies[0]);
 
-- 
2.34.1

Reply via email to