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

drm/amd/display: Fix incorrect size calculation for loop in dcn401

[WHY]
fe_clk_en and be_clk_sel have size of 4 but sizeof(fe_clk_en) has
byte size 16 which is lager than the array size.

[HOW]
Use ARRAY_SIZE for calculating size.

This fixes 2 OVERRUN issues reported by Coverity.

Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Acked-by: Zaeem Mohamed <zaeem.mohamed@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Alex Hung and committed by
Alex Deucher
d281b774 dd9d8c61

+1 -1
+1 -1
drivers/gpu/drm/amd/display/dc/dccg/dcn401/dcn401_dccg.c
··· 885 885 /* for DPMST, this backend could be used by multiple front end. 886 886 only disable the backend if this stream_enc_ins is the last active stream enc connected to this back_end*/ 887 887 uint8_t i; 888 - for (i = 0; i != link_enc_inst && i < sizeof(fe_clk_en); i++) { 888 + for (i = 0; i != link_enc_inst && i < ARRAY_SIZE(fe_clk_en); i++) { 889 889 if (fe_clk_en[i] && be_clk_sel[i] == link_enc_inst) 890 890 num_enabled_symclk_fe++; 891 891 }