Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amd/display: Check BIOS images before it is used

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>

authored by

Alex Hung and committed by
Alex Deucher
8b0ddf19 8092aa3a

+14
+14
drivers/gpu/drm/amd/display/dc/bios/bios_parser.c
··· 665 665 ss_table_header_include = ((ATOM_ASIC_INTERNAL_SS_INFO_V3 *) bios_get_image(&bp->base, 666 666 DATA_TABLES(ASIC_InternalSS_Info), 667 667 struct_size(ss_table_header_include, asSpreadSpectrum, 1))); 668 + if (!ss_table_header_include) 669 + return BP_RESULT_UNSUPPORTED; 670 + 668 671 table_size = 669 672 (le16_to_cpu(ss_table_header_include->sHeader.usStructureSize) 670 673 - sizeof(ATOM_COMMON_TABLE_HEADER)) ··· 1037 1034 &bp->base, 1038 1035 DATA_TABLES(ASIC_InternalSS_Info), 1039 1036 struct_size(header, asSpreadSpectrum, 1))); 1037 + if (!header) 1038 + return result; 1040 1039 1041 1040 memset(info, 0, sizeof(struct spread_spectrum_info)); 1042 1041 ··· 1112 1107 get_atom_data_table_revision(header, &revision); 1113 1108 1114 1109 tbl = GET_IMAGE(ATOM_SPREAD_SPECTRUM_INFO, DATA_TABLES(SS_Info)); 1110 + if (!tbl) 1111 + return result; 1115 1112 1116 1113 if (1 != revision.major || 2 > revision.minor) 1117 1114 return result; ··· 1641 1634 1642 1635 tbl = GET_IMAGE(ATOM_SPREAD_SPECTRUM_INFO, 1643 1636 DATA_TABLES(SS_Info)); 1637 + if (!tbl) 1638 + return number; 1644 1639 1645 1640 if (1 != revision.major || 2 > revision.minor) 1646 1641 return number; ··· 1725 1716 &bp->base, 1726 1717 DATA_TABLES(ASIC_InternalSS_Info), 1727 1718 struct_size(header_include, asSpreadSpectrum, 1))); 1719 + if (!header_include) 1720 + return 0; 1728 1721 1729 1722 size = (le16_to_cpu(header_include->sHeader.usStructureSize) 1730 1723 - sizeof(ATOM_COMMON_TABLE_HEADER)) ··· 1766 1755 header_include = ((ATOM_ASIC_INTERNAL_SS_INFO_V3 *) bios_get_image(&bp->base, 1767 1756 DATA_TABLES(ASIC_InternalSS_Info), 1768 1757 struct_size(header_include, asSpreadSpectrum, 1))); 1758 + if (!header_include) 1759 + return number; 1760 + 1769 1761 size = (le16_to_cpu(header_include->sHeader.usStructureSize) - 1770 1762 sizeof(ATOM_COMMON_TABLE_HEADER)) / 1771 1763 sizeof(ATOM_ASIC_SS_ASSIGNMENT_V3);