diff mbox series

drm/amd/display: Fix the uninitialized variable in enable_stream_features()

Message ID 20211218042226.2608212-1-yzhai003@ucr.edu
State Accepted
Commit 0726ed3065eeb910f9cea0c933bc021a848e00b3
Headers show
Series drm/amd/display: Fix the uninitialized variable in enable_stream_features() | expand

Commit Message

Yizhuo Zhai Dec. 18, 2021, 4:22 a.m. UTC
In function enable_stream_features(), the variable "old_downspread.raw"
could be uninitialized if core_link_read_dpcd() fails, however, it is
used in the later if statement, and further, core_link_write_dpcd()
may write random value, which is potentially unsafe.

Fixes: 6016cd9dba0f ("drm/amd/display: add helper for enabling mst stream features")
Cc: stable@vger.kernel.org
Signed-off-by: Yizhuo Zhai <yzhai003@ucr.edu>
---
 drivers/gpu/drm/amd/display/dc/core/dc_link.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Alex Deucher Dec. 22, 2021, 2:36 p.m. UTC | #1
Applied.  Thanks!

Alex

On Fri, Dec 17, 2021 at 11:22 PM Yizhuo Zhai <yzhai003@ucr.edu> wrote:
>
> In function enable_stream_features(), the variable "old_downspread.raw"
> could be uninitialized if core_link_read_dpcd() fails, however, it is
> used in the later if statement, and further, core_link_write_dpcd()
> may write random value, which is potentially unsafe.
>
> Fixes: 6016cd9dba0f ("drm/amd/display: add helper for enabling mst stream features")
> Cc: stable@vger.kernel.org
> Signed-off-by: Yizhuo Zhai <yzhai003@ucr.edu>
> ---
>  drivers/gpu/drm/amd/display/dc/core/dc_link.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
> index c8457babfdea..fd5a0e7eb029 100644
> --- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c
> +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
> @@ -1844,6 +1844,8 @@ static void enable_stream_features(struct pipe_ctx *pipe_ctx)
>                 union down_spread_ctrl old_downspread;
>                 union down_spread_ctrl new_downspread;
>
> +               memset(&old_downspread, 0, sizeof(old_downspread));
> +
>                 core_link_read_dpcd(link, DP_DOWNSPREAD_CTRL,
>                                 &old_downspread.raw, sizeof(old_downspread));
>
> --
> 2.25.1
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
index c8457babfdea..fd5a0e7eb029 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
@@ -1844,6 +1844,8 @@  static void enable_stream_features(struct pipe_ctx *pipe_ctx)
 		union down_spread_ctrl old_downspread;
 		union down_spread_ctrl new_downspread;
 
+		memset(&old_downspread, 0, sizeof(old_downspread));
+
 		core_link_read_dpcd(link, DP_DOWNSPREAD_CTRL,
 				&old_downspread.raw, sizeof(old_downspread));