[PATCH 2/2] drm/amd/pm: ensure the fw_info is not null before using it

Zhang, Jesse(Jie) Jesse.Zhang at amd.com
Wed Aug 14 08:59:14 UTC 2024


[AMD Official Use Only - AMD Internal Distribution Only]

This patch is
Reviewed-by: Jesse Zhang <jesse.zhang at amd.com>
-----Original Message-----
From: Huang, Tim <Tim.Huang at amd.com>
Sent: Friday, August 9, 2024 3:34 PM
To: amd-gfx at lists.freedesktop.org
Cc: Deucher, Alexander <Alexander.Deucher at amd.com>; Koenig, Christian <Christian.Koenig at amd.com>; Zhang, Jesse(Jie) <Jesse.Zhang at amd.com>; Zhou, Bob <Bob.Zhou at amd.com>; Huang, Tim <Tim.Huang at amd.com>
Subject: [PATCH 2/2] drm/amd/pm: ensure the fw_info is not null before using it

This resolves the dereference null return value warning reported by Coverity.

Signed-off-by: Tim Huang <tim.huang at amd.com>
---
 drivers/gpu/drm/amd/pm/powerplay/hwmgr/processpptables.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/processpptables.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/processpptables.c
index ca1c7ae8d146..f06b29e33ba4 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/processpptables.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/processpptables.c
@@ -1183,6 +1183,8 @@ static int init_overdrive_limits(struct pp_hwmgr *hwmgr,
        fw_info = smu_atom_get_data_table(hwmgr->adev,
                         GetIndexIntoMasterTable(DATA, FirmwareInfo),
                         &size, &frev, &crev);
+       PP_ASSERT_WITH_CODE(fw_info != NULL,
+                           "Missing firmware info!", return -EINVAL);

        if ((fw_info->ucTableFormatRevision == 1)
            && (le16_to_cpu(fw_info->usStructureSize) >= sizeof(ATOM_FIRMWARE_INFO_V1_4)))
--
2.43.0



More information about the amd-gfx mailing list