Skip to content

Commit a152687

Browse files
Alex Hungalexdeucher
Alex Hung
authored andcommitted
drm/amd/display: Avoid overflow assignment in link_dp_cts
sampling_rate is an uint8_t but is assigned an unsigned int, and thus it can overflow. As a result, sampling_rate is changed to uint32_t. Similarly, LINK_QUAL_PATTERN_SET has a size of 2 bits, and it should only be assigned to a value less or equal than 4. This fixes 2 INTEGER_OVERFLOW issues reported by Coverity. Signed-off-by: Alex Hung <[email protected]> Reviewed-by: Wenjing Liu <[email protected]> Tested-by: Daniel Wheeler <[email protected]> Signed-off-by: Rodrigo Siqueira <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent cead9ac commit a152687

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

drivers/gpu/drm/amd/display/dc/dc_dp_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ struct dp_audio_test_data_flags {
727727
struct dp_audio_test_data {
728728

729729
struct dp_audio_test_data_flags flags;
730-
uint8_t sampling_rate;
730+
uint32_t sampling_rate;
731731
uint8_t channel_count;
732732
uint8_t pattern_type;
733733
uint8_t pattern_period[8];

drivers/gpu/drm/amd/display/dc/link/accessories/link_dp_cts.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,8 @@ bool dp_set_test_pattern(
775775
core_link_read_dpcd(link, DP_TRAINING_PATTERN_SET,
776776
&training_pattern.raw,
777777
sizeof(training_pattern));
778-
training_pattern.v1_3.LINK_QUAL_PATTERN_SET = pattern;
778+
if (pattern <= PHY_TEST_PATTERN_END_DP11)
779+
training_pattern.v1_3.LINK_QUAL_PATTERN_SET = pattern;
779780
core_link_write_dpcd(link, DP_TRAINING_PATTERN_SET,
780781
&training_pattern.raw,
781782
sizeof(training_pattern));

drivers/gpu/drm/amd/display/include/dpcd_defs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ enum dpcd_phy_test_patterns {
7676
PHY_TEST_PATTERN_D10_2,
7777
PHY_TEST_PATTERN_SYMBOL_ERROR,
7878
PHY_TEST_PATTERN_PRBS7,
79+
PHY_TEST_PATTERN_END_DP11 = PHY_TEST_PATTERN_PRBS7,
7980
PHY_TEST_PATTERN_80BIT_CUSTOM,/* For DP1.2 only */
8081
PHY_TEST_PATTERN_CP2520_1,
8182
PHY_TEST_PATTERN_CP2520_2,

0 commit comments

Comments
 (0)