Skip to contentSkip to conversation

drm/amdgpu: Move null pointer dereference check

PATCH Applied Austin Kim 2 participants 2 messages Aug 30, 2019

Subsystems (2)
lore
Share & tools
lore

Austin Kim

author
#0 lore raw

PATCH 1/1 drm/amdgpu: Move null pointer dereference check

Null pointer dereference check should have been checked, ahead of below routine.

	struct amdgpu_device *adev = hwmgr->adev;

With this commit, it could avoid potential NULL dereference.

---
 drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c +3 -2
index 8189fe4..4728aa2 100644
@@ -722,16 +722,17 @@ static int smu8_request_smu_load_fw(struct pp_hwmgr *hwmgr)
 
 static int smu8_start_smu(struct pp_hwmgr *hwmgr)
 {
-	struct amdgpu_device *adev = hwmgr->adev;
+	struct amdgpu_device *adev;
 
 	uint32_t index = SMN_MP1_SRAM_START_ADDR +
 			 SMU8_FIRMWARE_HEADER_LOCATION +
 			 offsetof(struct SMU8_Firmware_Header, Version);
 
-
 	if (hwmgr == NULL || hwmgr->device == NULL)
 		return -EINVAL;
 
+	adev = hwmgr->adev;
+
 	cgs_write_register(hwmgr->device, mmMP0PUB_IND_INDEX, index);
 	hwmgr->smu_version = cgs_read_register(hwmgr->device, mmMP0PUB_IND_DATA);
 	pr_info("smu version %02d.%02d.%02d\n",
Signature · 1 line
2.6.2
Applied
#1 lore raw
Quoted 8 lines · Austin Kim

Null pointer dereference check should have been checked, ahead of below routine.

        struct amdgpu_device *adev = hwmgr->adev;

With this commit, it could avoid potential NULL dereference.

Applied. thanks!

Alex

Quoted 31 lines
---
 drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c +3 -3
index 8189fe4..4728aa2 100644
@@ -722,16 +722,17 @@ static int smu8_request_smu_load_fw(struct pp_hwmgr *hwmgr)
 
 static int smu8_start_smu(struct pp_hwmgr *hwmgr)
 {
-       struct amdgpu_device *adev = hwmgr->adev;
+       struct amdgpu_device *adev;
 
        uint32_t index = SMN_MP1_SRAM_START_ADDR +
                         SMU8_FIRMWARE_HEADER_LOCATION +
                         offsetof(struct SMU8_Firmware_Header, Version);
 
-
        if (hwmgr == NULL || hwmgr->device == NULL)
                return -EINVAL;
 
+       adev = hwmgr->adev;
+
        cgs_write_register(hwmgr->device, mmMP0PUB_IND_INDEX, index);
        hwmgr->smu_version = cgs_read_register(hwmgr->device, mmMP0PUB_IND_DATA);
        pr_info("smu version %02d.%02d.%02d\n",
--

2.6.2

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx