Skip to content

Commit e46b70a

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 de44970 commit e46b70a

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,9 @@ static enum bp_result get_ss_info_v3_1(
665665
ss_table_header_include = ((ATOM_ASIC_INTERNAL_SS_INFO_V3 *) bios_get_image(&bp->base,
666666
DATA_TABLES(ASIC_InternalSS_Info),
667667
struct_size(ss_table_header_include, asSpreadSpectrum, 1)));
668+
if (!ss_table_header_include)
669+
return BP_RESULT_UNSUPPORTED;
670+
668671
table_size =
669672
(le16_to_cpu(ss_table_header_include->sHeader.usStructureSize)
670673
- sizeof(ATOM_COMMON_TABLE_HEADER))
@@ -1034,6 +1037,8 @@ static enum bp_result get_ss_info_from_internal_ss_info_tbl_V2_1(
10341037
&bp->base,
10351038
DATA_TABLES(ASIC_InternalSS_Info),
10361039
struct_size(header, asSpreadSpectrum, 1)));
1040+
if (!header)
1041+
return result;
10371042

10381043
memset(info, 0, sizeof(struct spread_spectrum_info));
10391044

@@ -1107,6 +1112,8 @@ static enum bp_result get_ss_info_from_ss_info_table(
11071112
get_atom_data_table_revision(header, &revision);
11081113

11091114
tbl = GET_IMAGE(ATOM_SPREAD_SPECTRUM_INFO, DATA_TABLES(SS_Info));
1115+
if (!tbl)
1116+
return result;
11101117

11111118
if (1 != revision.major || 2 > revision.minor)
11121119
return result;
@@ -1634,6 +1641,8 @@ static uint32_t get_ss_entry_number_from_ss_info_tbl(
16341641

16351642
tbl = GET_IMAGE(ATOM_SPREAD_SPECTRUM_INFO,
16361643
DATA_TABLES(SS_Info));
1644+
if (!tbl)
1645+
return number;
16371646

16381647
if (1 != revision.major || 2 > revision.minor)
16391648
return number;
@@ -1716,6 +1725,8 @@ static uint32_t get_ss_entry_number_from_internal_ss_info_tbl_v2_1(
17161725
&bp->base,
17171726
DATA_TABLES(ASIC_InternalSS_Info),
17181727
struct_size(header_include, asSpreadSpectrum, 1)));
1728+
if (!header_include)
1729+
return 0;
17191730

17201731
size = (le16_to_cpu(header_include->sHeader.usStructureSize)
17211732
- sizeof(ATOM_COMMON_TABLE_HEADER))
@@ -1755,6 +1766,9 @@ static uint32_t get_ss_entry_number_from_internal_ss_info_tbl_V3_1(
17551766
header_include = ((ATOM_ASIC_INTERNAL_SS_INFO_V3 *) bios_get_image(&bp->base,
17561767
DATA_TABLES(ASIC_InternalSS_Info),
17571768
struct_size(header_include, asSpreadSpectrum, 1)));
1769+
if (!header_include)
1770+
return number;
1771+
17581772
size = (le16_to_cpu(header_include->sHeader.usStructureSize) -
17591773
sizeof(ATOM_COMMON_TABLE_HEADER)) /
17601774
sizeof(ATOM_ASIC_SS_ASSIGNMENT_V3);

0 commit comments

Comments
 (0)