[PATCH] drm/amd/display: Avoid reading audio pattern past AUDIO_CHANNELS_COUNT

Alex Deucher alexdeucher at gmail.com
Thu Apr 28 17:44:06 UTC 2022


On Thu, Apr 28, 2022 at 1:41 PM Harry Wentland <harry.wentland at amd.com> wrote:
>
> A faulty receiver might report an erroneous channel count. We
> should guard against reading beyond AUDIO_CHANNELS_COUNT as
> that would overflow the dpcd_pattern_period array.
>
> Signed-off-by: Harry Wentland <harry.wentland at amd.com>

Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

> ---
>  drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
> index c15c46b81111..55a5a6a49fe2 100644
> --- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
> +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
> @@ -4464,7 +4464,7 @@ static void dp_test_get_audio_test_data(struct dc_link *link, bool disable_video
>                 &dpcd_pattern_type.value,
>                 sizeof(dpcd_pattern_type));
>
> -       channel_count = dpcd_test_mode.bits.channel_count + 1;
> +       channel_count = min(dpcd_test_mode.bits.channel_count + 1, AUDIO_CHANNELS_COUNT);
>
>         // read pattern periods for requested channels when sawTooth pattern is requested
>         if (dpcd_pattern_type.value == AUDIO_TEST_PATTERN_SAWTOOTH ||
> --
> 2.35.1
>


More information about the amd-gfx mailing list