Skip to content

Commit e50bec6

Browse files
Alex Hunggregkh
authored andcommitted
drm/amd/display: Check BIOS images before it is used
[ Upstream commit 8b0ddf1 ] BIOS images may fail to load and null checks are added before they are used. This fixes 6 NULL_RETURNS issues reported by Coverity. Reviewed-by: Harry Wentland <harry.wentland@amd.com> Acked-by: Hamza Mahfooz <hamza.mahfooz@amd.com> Signed-off-by: Alex Hung <alex.hung@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 67cf14c commit e50bec6

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,9 @@ static enum bp_result get_ss_info_v3_1(
667667
ss_table_header_include = ((ATOM_ASIC_INTERNAL_SS_INFO_V3 *) bios_get_image(&bp->base,
668668
DATA_TABLES(ASIC_InternalSS_Info),
669669
struct_size(ss_table_header_include, asSpreadSpectrum, 1)));
670+
if (!ss_table_header_include)
671+
return BP_RESULT_UNSUPPORTED;
672+
670673
table_size =
671674
(le16_to_cpu(ss_table_header_include->sHeader.usStructureSize)
672675
- sizeof(ATOM_COMMON_TABLE_HEADER))
@@ -1036,6 +1039,8 @@ static enum bp_result get_ss_info_from_internal_ss_info_tbl_V2_1(
10361039
&bp->base,
10371040
DATA_TABLES(ASIC_InternalSS_Info),
10381041
struct_size(header, asSpreadSpectrum, 1)));
1042+
if (!header)
1043+
return result;
10391044

10401045
memset(info, 0, sizeof(struct spread_spectrum_info));
10411046

@@ -1109,6 +1114,8 @@ static enum bp_result get_ss_info_from_ss_info_table(
11091114
get_atom_data_table_revision(header, &revision);
11101115

11111116
tbl = GET_IMAGE(ATOM_SPREAD_SPECTRUM_INFO, DATA_TABLES(SS_Info));
1117+
if (!tbl)
1118+
return result;
11121119

11131120
if (1 != revision.major || 2 > revision.minor)
11141121
return result;
@@ -1636,6 +1643,8 @@ static uint32_t get_ss_entry_number_from_ss_info_tbl(
16361643

16371644
tbl = GET_IMAGE(ATOM_SPREAD_SPECTRUM_INFO,
16381645
DATA_TABLES(SS_Info));
1646+
if (!tbl)
1647+
return number;
16391648

16401649
if (1 != revision.major || 2 > revision.minor)
16411650
return number;
@@ -1718,6 +1727,8 @@ static uint32_t get_ss_entry_number_from_internal_ss_info_tbl_v2_1(
17181727
&bp->base,
17191728
DATA_TABLES(ASIC_InternalSS_Info),
17201729
struct_size(header_include, asSpreadSpectrum, 1)));
1730+
if (!header_include)
1731+
return 0;
17211732

17221733
size = (le16_to_cpu(header_include->sHeader.usStructureSize)
17231734
- sizeof(ATOM_COMMON_TABLE_HEADER))
@@ -1756,6 +1767,9 @@ static uint32_t get_ss_entry_number_from_internal_ss_info_tbl_V3_1(
17561767
header_include = ((ATOM_ASIC_INTERNAL_SS_INFO_V3 *) bios_get_image(&bp->base,
17571768
DATA_TABLES(ASIC_InternalSS_Info),
17581769
struct_size(header_include, asSpreadSpectrum, 1)));
1770+
if (!header_include)
1771+
return number;
1772+
17591773
size = (le16_to_cpu(header_include->sHeader.usStructureSize) -
17601774
sizeof(ATOM_COMMON_TABLE_HEADER)) /
17611775
sizeof(ATOM_ASIC_SS_ASSIGNMENT_V3);

0 commit comments

Comments
 (0)