Skip to content

Commit 0484e05

Browse files
sohaibndalexdeucher
authored andcommitted
drm/amd/display: fixed integer types and null check locations
[why]: issues fixed: - comparison with wider integer type in loop condition which can cause infinite loops - pointer dereference before null check Cc: Mario Limonciello <[email protected]> Cc: Alex Deucher <[email protected]> Cc: [email protected] Reviewed-by: Josip Pavic <[email protected]> Acked-by: Aurabindo Pillai <[email protected]> Signed-off-by: Sohaib Nadeem <[email protected]> Tested-by: Daniel Wheeler <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 46806e5 commit 0484e05

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1850,19 +1850,21 @@ static enum bp_result get_firmware_info_v3_2(
18501850
/* Vega12 */
18511851
smu_info_v3_2 = GET_IMAGE(struct atom_smu_info_v3_2,
18521852
DATA_TABLES(smu_info));
1853-
DC_LOG_BIOS("gpuclk_ss_percentage (unit of 0.001 percent): %d\n", smu_info_v3_2->gpuclk_ss_percentage);
18541853
if (!smu_info_v3_2)
18551854
return BP_RESULT_BADBIOSTABLE;
18561855

1856+
DC_LOG_BIOS("gpuclk_ss_percentage (unit of 0.001 percent): %d\n", smu_info_v3_2->gpuclk_ss_percentage);
1857+
18571858
info->default_engine_clk = smu_info_v3_2->bootup_dcefclk_10khz * 10;
18581859
} else if (revision.minor == 3) {
18591860
/* Vega20 */
18601861
smu_info_v3_3 = GET_IMAGE(struct atom_smu_info_v3_3,
18611862
DATA_TABLES(smu_info));
1862-
DC_LOG_BIOS("gpuclk_ss_percentage (unit of 0.001 percent): %d\n", smu_info_v3_3->gpuclk_ss_percentage);
18631863
if (!smu_info_v3_3)
18641864
return BP_RESULT_BADBIOSTABLE;
18651865

1866+
DC_LOG_BIOS("gpuclk_ss_percentage (unit of 0.001 percent): %d\n", smu_info_v3_3->gpuclk_ss_percentage);
1867+
18661868
info->default_engine_clk = smu_info_v3_3->bootup_dcefclk_10khz * 10;
18671869
}
18681870

@@ -2422,10 +2424,11 @@ static enum bp_result get_integrated_info_v11(
24222424
info_v11 = GET_IMAGE(struct atom_integrated_system_info_v1_11,
24232425
DATA_TABLES(integratedsysteminfo));
24242426

2425-
DC_LOG_BIOS("gpuclk_ss_percentage (unit of 0.001 percent): %d\n", info_v11->gpuclk_ss_percentage);
24262427
if (info_v11 == NULL)
24272428
return BP_RESULT_BADBIOSTABLE;
24282429

2430+
DC_LOG_BIOS("gpuclk_ss_percentage (unit of 0.001 percent): %d\n", info_v11->gpuclk_ss_percentage);
2431+
24292432
info->gpu_cap_info =
24302433
le32_to_cpu(info_v11->gpucapinfo);
24312434
/*
@@ -2637,11 +2640,12 @@ static enum bp_result get_integrated_info_v2_1(
26372640

26382641
info_v2_1 = GET_IMAGE(struct atom_integrated_system_info_v2_1,
26392642
DATA_TABLES(integratedsysteminfo));
2640-
DC_LOG_BIOS("gpuclk_ss_percentage (unit of 0.001 percent): %d\n", info_v2_1->gpuclk_ss_percentage);
26412643

26422644
if (info_v2_1 == NULL)
26432645
return BP_RESULT_BADBIOSTABLE;
26442646

2647+
DC_LOG_BIOS("gpuclk_ss_percentage (unit of 0.001 percent): %d\n", info_v2_1->gpuclk_ss_percentage);
2648+
26452649
info->gpu_cap_info =
26462650
le32_to_cpu(info_v2_1->gpucapinfo);
26472651
/*
@@ -2799,11 +2803,11 @@ static enum bp_result get_integrated_info_v2_2(
27992803
info_v2_2 = GET_IMAGE(struct atom_integrated_system_info_v2_2,
28002804
DATA_TABLES(integratedsysteminfo));
28012805

2802-
DC_LOG_BIOS("gpuclk_ss_percentage (unit of 0.001 percent): %d\n", info_v2_2->gpuclk_ss_percentage);
2803-
28042806
if (info_v2_2 == NULL)
28052807
return BP_RESULT_BADBIOSTABLE;
28062808

2809+
DC_LOG_BIOS("gpuclk_ss_percentage (unit of 0.001 percent): %d\n", info_v2_2->gpuclk_ss_percentage);
2810+
28072811
info->gpu_cap_info =
28082812
le32_to_cpu(info_v2_2->gpucapinfo);
28092813
/*

drivers/gpu/drm/amd/display/dc/link/link_validation.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ bool link_validate_dpia_bandwidth(const struct dc_stream_state *stream, const un
361361
struct dc_link *dpia_link[MAX_DPIA_NUM] = {0};
362362
int num_dpias = 0;
363363

364-
for (uint8_t i = 0; i < num_streams; ++i) {
364+
for (unsigned int i = 0; i < num_streams; ++i) {
365365
if (stream[i].signal == SIGNAL_TYPE_DISPLAY_PORT) {
366366
/* new dpia sst stream, check whether it exceeds max dpia */
367367
if (num_dpias >= MAX_DPIA_NUM)

0 commit comments

Comments
 (0)