Skip to content

Commit

Permalink
drm/amdgpu: Move null pointer dereference check
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Austin Kim <austindh.kim@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
  • Loading branch information
Austin Kim authored and Alex Deucher committed Aug 30, 2019
1 parent 20c14ee commit 9c9284f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 9c9284f

Please sign in to comment.