drm/amd/pm: add missing error handling in function smu_v13_0_6_allocate_dpm_context
Subsystems (3)
PATCH 1/1 drm/amd/pm: add missing error handling in function smu_v13_0_6_allocate_dpm_context
Check return value to avoid null pointer dereference.
--- drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c +3 -0
@@ -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 ]);
Signature · 1 line
2.34.1
[AMD Official Use Only - AMD Internal Distribution Only]
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Bob Zhou
Sent: Friday, May 31, 2024 3:36 PM
To: [email protected]; Huang, Tim <[email protected]>; Zhang, Jesse(Jie) <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Zhou, Bob <[email protected]>
Subject: [PATCH] drm/amd/pm: add missing error handling in function smu_v13_0_6_allocate_dpm_context
Check return value to avoid null pointer dereference.
--- drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c +2 -0
@@ -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 ;
[Kevin]:
the 'smu_dpm->dpm_context' needs to be released together to avoid memory leak.
Best Regards,
Kevin
+
if (!(smu->adev->flags & AMD_IS_APU)) {
policy = &(smu_dpm->dpm_policies->policies[0]);--
2.34.1
[AMD Official Use Only - AMD Internal Distribution Only]
Good catch! Thanks for your comments. I will fix this on next patch.
Regards,
Bob
-----Original Message-----
From: Wang, Yang(Kevin) <[email protected]>
Sent: 2024年5月31日 15:43
To: Zhou, Bob <[email protected]>; [email protected]; Huang, Tim <[email protected]>; Zhang, Jesse(Jie) <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Zhou, Bob <[email protected]>
Subject: RE: [PATCH] drm/amd/pm: add missing error handling in function smu_v13_0_6_allocate_dpm_context
[AMD Official Use Only - AMD Internal Distribution Only]
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Bob Zhou
Sent: Friday, May 31, 2024 3:36 PM
To: [email protected]; Huang, Tim <[email protected]>; Zhang, Jesse(Jie) <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Zhou, Bob <[email protected]>
Subject: [PATCH] drm/amd/pm: add missing error handling in function smu_v13_0_6_allocate_dpm_context
Check return value to avoid null pointer dereference.
--- drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c +2 -0
@@ -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 ;
[Kevin]:
the 'smu_dpm->dpm_context' needs to be released together to avoid memory leak.
Best Regards,
Kevin
+
if (!(smu->adev->flags & AMD_IS_APU)) {
policy = &(smu_dpm->dpm_policies->policies[0]);--
2.34.1