Skip to contentSkip to conversation

drm/amdgpu: ensure the connector is not null before using it

PATCH In review Tim Huang 2 participants 4 messages Aug 9, 2024 – Aug 14, 2024

Subsystems (3)
lore
Share & tools
lore

Tim Huang

author
#0 lore raw

PATCH 1/2 drm/amdgpu: ensure the connector is not null before using it

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

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +1 -1
index 092ec11258cd..046d4c4e0299 100644
@@ -1474,7 +1474,7 @@ bool amdgpu_display_crtc_scaling_mode_fixup(struct drm_crtc *crtc,
 		if ((!(mode->flags & DRM_MODE_FLAG_INTERLACE)) &&
 		    ((amdgpu_encoder->underscan_type == UNDERSCAN_ON) ||
 		     ((amdgpu_encoder->underscan_type == UNDERSCAN_AUTO) &&
-		      connector->display_info.is_hdmi &&
+		      connector && connector->display_info.is_hdmi &&
 		      amdgpu_display_is_hdtv_mode(mode)))) {
 			if (amdgpu_encoder->underscan_hborder != 0)
 				amdgpu_crtc->h_border = amdgpu_encoder->underscan_hborder;
Signature · 1 line
2.43.0
author
#1 lore raw

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.

---
 drivers/gpu/drm/amd/pm/powerplay/hwmgr/processpptables.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/processpptables.c +2 -0
index ca1c7ae8d146..f06b29e33ba4 100644
@@ -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)))
Signature · 1 line
2.43.0
Reviewed-by on v1 2/2
#2 lore raw

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

[AMD Official Use Only - AMD Internal Distribution Only]

This patch is

-----Original Message-----
From: Huang, Tim <[email protected]>
Sent: Friday, August 9, 2024 3:34 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Zhang, Jesse(Jie) <[email protected]>; Zhou, Bob <[email protected]>; Huang, Tim <[email protected]>
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.

---
 drivers/gpu/drm/amd/pm/powerplay/hwmgr/processpptables.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/processpptables.c +2 -0
index ca1c7ae8d146..f06b29e33ba4 100644
@@ -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

Reviewed-by on v1 1/2
#3 lore raw
In reply to Tim Huang

[AMD Official Use Only - AMD Internal Distribution Only]

This patch is

-----Original Message-----
From: Huang, Tim <[email protected]>
Sent: Friday, August 9, 2024 3:34 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Zhang, Jesse(Jie) <[email protected]>; Zhou, Bob <[email protected]>; Huang, Tim <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: ensure the connector is not null before using it

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

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +1 -1
index 092ec11258cd..046d4c4e0299 100644
@@ -1474,7 +1474,7 @@ bool amdgpu_display_crtc_scaling_mode_fixup(struct drm_crtc *crtc,
                if ((!(mode->flags & DRM_MODE_FLAG_INTERLACE)) &&
                    ((amdgpu_encoder->underscan_type == UNDERSCAN_ON) ||
                     ((amdgpu_encoder->underscan_type == UNDERSCAN_AUTO) &&
-                     connector->display_info.is_hdmi &&
+                     connector && connector->display_info.is_hdmi &&
                      amdgpu_display_is_hdtv_mode(mode)))) {
                        if (amdgpu_encoder->underscan_hborder != 0)
                                amdgpu_crtc->h_border = amdgpu_encoder->underscan_hborder;

--
2.43.0